d5a75ba09ae0595ca284fd806475eb8d3f771387,word_language_model/generate.py,,,#,18

Before Change


    for i in range(args.nwords):

        output, hidden = model(Variable(input, volatile=True), hidden)
        gen = torch.multinomial(output[0].data.div(temperature).exp().cpu(), 1)[0][0] // FIXME: multinomial is only for CPU
        input.fill_(gen)
        word = corpus.dic.idx2word[gen]
        outf.write(word)

After Change


    if not args.cuda:
        print("WARNING: You have a CUDA device, so you should probably run with --cuda")
    else:
        torch.cuda.manual_seed(args.seed)

if args.temperature < 1e-3:
    parser.error("--temperature has to be greater or equal 1e-3")
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: pytorch/examples
Commit Name: d5a75ba09ae0595ca284fd806475eb8d3f771387
Time: 2017-01-17
Author: adam.paszke@gmail.com
File Name: word_language_model/generate.py
Class Name:
Method Name:


Project Name: dmlc/dgl
Commit Name: 7a50be64b75a82ee4380284b4a74496d18106b0a
Time: 2018-04-22
Author: zzhang@gmail.com
File Name: mx.py
Class Name:
Method Name: