hunkim / PyTorchZeroToAll

Simple PyTorch Tutorials Zero to ALL!
http://bit.ly/PyTorchZeroAll
3.89k stars 1.2k forks source link

Error in 13_3_char_rnn.py #46

Open KawhiZhao opened 5 years ago

KawhiZhao commented 5 years ago

Training for 100 epochs... Traceback (most recent call last): File "F:/pytorch/PyTorchZeroToAll-master/13_3_char_rnn.py", line 142, in loss = train(lines[0]) # Batch size is 1 File "F:/pytorch/PyTorchZeroToAll-master/13_3_char_rnn.py", line 117, in train loss += criterion(output, target[c]) File "C:\Users\hh\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 477, in call result = self.forward(*input, **kwargs) File "C:\Users\hh\Anaconda3\lib\site-packages\torch\nn\modules\loss.py", line 862, in forward ignore_index=self.ignore_index, reduction=self.reduction) File "C:\Users\hh\Anaconda3\lib\site-packages\torch\nn\functional.py", line 1550, in cross_entropy return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction) File "C:\Users\hh\Anaconda3\lib\site-packages\torch\nn\functional.py", line 1403, in nll_loss if input.size(0) != target.size(0): RuntimeError: dimension specified as 0 but tensor has no dimensions

Process finished with exit code 1