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
return vocabs[sample]
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:
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 2
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: lebedov/scikit-cuda
Commit Name: 6e4757e57341c0714ac83cfdf106058df12aa52d
Time: 2019-08-03
Author: udrobots@gmail.com
File Name: demos/pca_demo.py
Class Name:
Method Name:
Project Name: scipy/scipy
Commit Name: bd6871fa3f9c39227a02cf3e9a37e5515d27d900
Time: 2019-11-12
Author: s@fuglede.dk
File Name: benchmarks/benchmarks/sparse_csgraph_matching.py
Class Name: MaximumBipartiteMatching
Method Name: setup