e24303de503ee56515e33fa4e9ff3ab05eede5b8,compose_poem.py,,to_word,#Any#Any#,32

Before Change




def to_word(predict, vocabs):
    t = np.cumsum(predict)
    s = np.sum(predict)
    sample = int(np.searchsorted(t, np.random.rand(1) * s))
    if sample > len(vocabs):
        sample = len(vocabs) - 1

After Change


def to_word(predict, vocabs):
    predict = predict[0]       
    predict /= np.sum(predict)
    sample = np.random.choice(np.arange(len(predict)), p=predict)
    if sample > len(vocabs):
        return vocabs[-1]
    else:
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: jinfagang/tensorflow_poems
Commit Name: e24303de503ee56515e33fa4e9ff3ab05eede5b8
Time: 2018-06-03
Author: 30965609+Freakwill@users.noreply.github.com
File Name: compose_poem.py
Class Name:
Method Name: to_word


Project Name: nipy/dipy
Commit Name: 4d63ba15b3fb53a0f3613f81fe1bd94c65d5bf0b
Time: 2010-05-07
Author: mrbago+git@gmail.com
File Name: dipy/core/qball.py
Class Name: ModelParams
Method Name: __init__


Project Name: tristandeleu/pytorch-maml-rl
Commit Name: 7237312ab4b6a43c81fff4b64d8ef4e6fb08eba8
Time: 2020-01-07
Author: tristan.deleu@gmail.com
File Name: maml_rl/baseline.py
Class Name: LinearFeatureBaseline
Method Name: _feature