01d5e7bc4782daafcfa99e035c1bdbe13a985145,examples/lstm_text_generation.py,,sample,#Any#Any#,62

Before Change


    // helper function to sample an index from a probability array
    a = np.log(a) / temperature
    a = np.exp(a) / np.sum(np.exp(a))
    return np.argmax(np.random.multinomial(1, a, 1))

// train the model, output generated text after each iteration
for iteration in range(1, 60):
    print()

After Change



def sample(preds, temperature=1.0):
    // helper function to sample an index from a probability array
    preds = np.asarray(preds).astype("float64")
    preds = np.log(preds) / temperature
    exp_preds = np.exp(preds)
    preds = exp_preds / np.sum(exp_preds)
    probas = np.random.multinomial(1, preds, 1)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 2

Instances


Project Name: keras-team/keras
Commit Name: 01d5e7bc4782daafcfa99e035c1bdbe13a985145
Time: 2016-07-16
Author: francois.chollet@gmail.com
File Name: examples/lstm_text_generation.py
Class Name:
Method Name: sample


Project Name: dmlc/gluon-cv
Commit Name: b30cdf3a1a977927345f407a4c25be2884cfee7f
Time: 2018-09-06
Author: 8041160+zhanghang1989@users.noreply.github.com
File Name: tests/unittests/test_utils_segmentation.py
Class Name:
Method Name: test_segmentation_utils


Project Name: d2l-ai/d2l-zh
Commit Name: 33e80de90362b279744675a48caf9be1110669ab
Time: 2018-04-04
Author: asv325@gmail.com
File Name: utils.py
Class Name:
Method Name: evaluate_accuracy