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")