Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 12_2_hello_rnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

# As we have one batch of samples, we will change them to variables only once
inputs = Variable(torch.Tensor(x_one_hot))
labels = Variable(torch.LongTensor(y_data))
labels = Variable(torch.LongTensor(y_data)).view(-1, 1)

num_classes = 5
input_size = 5 # one-hot size
Expand Down Expand Up @@ -77,7 +77,7 @@ def init_hidden(self):
sys.stdout.write(idx2char[idx.data[0]])
loss += criterion(output, label)

print(", epoch: %d, loss: %1.3f" % (epoch + 1, loss.data[0]))
print(", epoch: %d, loss: %1.3f" % (epoch + 1, loss.data))

loss.backward()
optimizer.step()
Expand Down