From 4510fd589010c2a9eaa5115ae3c48fd5b2dbf22a Mon Sep 17 00:00:00 2001 From: Rodion Kryuchkov Date: Mon, 24 May 2021 12:05:01 +0300 Subject: [PATCH] Update chatbot_tutorial.py Fix lengths to cpu. See issue #1300 --- beginner_source/chatbot_tutorial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beginner_source/chatbot_tutorial.py b/beginner_source/chatbot_tutorial.py index 103efa93dcb..de5a97e3492 100644 --- a/beginner_source/chatbot_tutorial.py +++ b/beginner_source/chatbot_tutorial.py @@ -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