if args.cuda:
input = input.cuda()
temperature = max(args.temperature, 1e-3)
with open(args.outf, "w") as outf:
for i in range(args.nwords):
output, hidden = model(Variable(input, volatile=True), hidden)
After Change
with open(args.outf, "w") as outf:
for i in range(args.words):
output, hidden = model(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 " "))