You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
line 78 of 12_2_hello_rnn.py
What's wrong with it? loss += criterion(output, label)
$ python 12_2_hello_rnn.py
Model(
(rnn): RNN(5, 5, batch_first=True)
)
predicted string: lTraceback (most recent call last):
File "12_2_hello_rnn.py", line 78, in
loss += criterion(output, label)
File "/home/jiapei/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in call
result = self.forward(*input, **kwargs)
File "/home/jiapei/.local/lib/python3.6/site-packages/torch/nn/modules/loss.py", line 759, in forward
self.ignore_index, self.reduce)
File "/home/jiapei/.local/lib/python3.6/site-packages/torch/nn/functional.py", line 1442, in cross_entropy
return nll_loss(log_softmax(input, 1), target, weight, size_average, ignore_index, reduce)
File "/home/jiapei/.local/lib/python3.6/site-packages/torch/nn/functional.py", line 1328, in nll_loss
if input.size(0) != target.size(0):
RuntimeError: dimension specified as 0 but tensor has no dimensions
The text was updated successfully, but these errors were encountered:
I ran into the same issue, guessing this happened from a recent update in pytorch . @jiapei100
A solution, though I am sure this is not the best way, was adding this before line 78 label = label.unsqueeze(0)
Is this a better solution? Adding this after line 19@hunkim y_data = [[y] for y in y_data]
line 78 of 12_2_hello_rnn.py
What's wrong with it?
loss += criterion(output, label)
The text was updated successfully, but these errors were encountered: