Skip to content

Commit

Permalink
Update chatbot_tutorial.py (pytorch#1535)
Browse files Browse the repository at this point in the history
Fix lengths to cpu. See issue pytorch#1300

Co-authored-by: Brian Johnson <brianjo@fb.com>
  • Loading branch information
krkv and brianjo committed May 25, 2021
1 parent ee37770 commit fd97ed4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion beginner_source/chatbot_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ def evaluate(encoder, decoder, searcher, voc, sentence, max_length=MAX_LENGTH):
input_batch = torch.LongTensor(indexes_batch).transpose(0, 1)
# Use appropriate device
input_batch = input_batch.to(device)
lengths = lengths.to(device)
lengths = lengths.to("cpu")
# Decode sentence with searcher
tokens, scores = searcher(input_batch, lengths, max_length)
# indexes -> words
Expand Down

0 comments on commit fd97ed4

Please sign in to comment.