PyTorchZeroToAll icon indicating copy to clipboard operation
PyTorchZeroToAll copied to clipboard

Fixed dimension bugs in 12_2_hello_rnn.py

Open kibitzing opened this issue 6 years ago • 1 comments

Error messages were

  1. "RuntimeError: dimension specified as 0 but tensor has no dimensions". (line: 24) --> I changed the dimension using '.view'(-1, 1)' to make the label dimension to be 1 instead of "no dimensions"
  2. "IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number" (line: 80) --> Since the output of the Cross Entropy Loss here has no dimension, deleted the index term '[0]'.

It was tested with Pytorch 1.1.

kibitzing avatar Jun 23 '19 16:06 kibitzing

Could you check if the new merge fixed this problem? Thanks!

hunkim avatar Jun 15 '20 22:06 hunkim