From 4328980cfe1bd12fe2ae3d825cd35c35d99bc76c Mon Sep 17 00:00:00 2001 From: Mehrdad Yazdani Date: Tue, 31 Jul 2018 09:30:24 -0700 Subject: [PATCH] reshape target label label dimension mismatch causes error in 0.4.1 --- 12_2_hello_rnn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/12_2_hello_rnn.py b/12_2_hello_rnn.py index c0364e3..257fa41 100644 --- a/12_2_hello_rnn.py +++ b/12_2_hello_rnn.py @@ -75,7 +75,7 @@ def init_hidden(self): hidden, output = model(hidden, input) val, idx = output.max(1) sys.stdout.write(idx2char[idx.data[0]]) - loss += criterion(output, label) + loss += criterion(output, label.view(1)) print(", epoch: %d, loss: %1.3f" % (epoch + 1, loss.data[0]))