a7cd7a15a9baf741f2b4fcd32f3d8055827889b5,examples/word_language_model/generate.py,,,#,10

Before Change


with open(args.outf, "w") as outf:
    for i in range(args.words):
        output, hidden = learner.module_(input, hidden)
        word_weights = output.squeeze().data.div(args.temperature).exp().cpu()
        word_idx = torch.multinomial(word_weights, 1)[0]
        input.data.fill_(word_idx)
        word = corpus.dictionary.idx2word[word_idx]

        outf.write(word + ("\n" if i % 20 == 19 else " "))

After Change


        word_idx, hidden = learner.sample(input=input,
                                          temperature=args.temperature,
                                          hidden=hidden)
        input = inferno.utils.to_var(torch.LongTensor([[word_idx]]),
                                     use_cuda=args.cuda)

        word = corpus.dictionary.idx2word[word_idx]
        outf.write(word + ("\n" if i % 20 == 19 else " "))
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: dnouri/skorch
Commit Name: a7cd7a15a9baf741f2b4fcd32f3d8055827889b5
Time: 2017-08-08
Author: marian.tietz@ottogroup.com
File Name: examples/word_language_model/generate.py
Class Name:
Method Name:


Project Name: tensorflow/magenta
Commit Name: f2559da66ce4435a8d3a8e17dd1e4fb18508151d
Time: 2021-03-25
Author: no-reply@google.com
File Name: magenta/models/coconet/lib_graph.py
Class Name: CoconetGraph
Method Name: apply_convolution


Project Name: mozilla/TTS
Commit Name: 5750090fcd4a6718608c7357e3890f5b2a545ae0
Time: 2018-03-22
Author: egolge@mozilla.com
File Name: layers/tacotron.py
Class Name: Decoder
Method Name: forward