yunjey / pytorch-tutorial

PyTorch Tutorial for Deep Learning Researchers
MIT License
29.79k stars 8.03k forks source link

Something wrong about RNN tutorial #151

Closed wuyifan18 closed 5 years ago

wuyifan18 commented 5 years ago

https://github.com/yunjey/pytorch-tutorial/blob/4896cefea1eb86cc96ff363c84767ca94cb559c6/tutorials/02-intermediate/recurrent_neural_network/main.py#L54-L57

First of all, thanks for your great tutorial on pytorch! It's a great help for beginners. In the line 54, the output of 'nn.LSTM' has been changed in pytorch 1.0, the shape of output is (seq_len, batch, num_directions * hidden_size) respectively now. And in line 57, it should be out[-1:, , :] not out[:, -1, :]
@yunjey : )

wuyifan18 commented 5 years ago

Sorry, I don't notice the parameter batch_first in 'nn.LSTM' which If true the input and output tensors are provided as (batch, seq, feature). I close the issue now.