LSTM_LN icon indicating copy to clipboard operation
LSTM_LN copied to clipboard

batch first mode causes some error

Open GuanlinLee opened this issue 5 years ago • 6 comments

`if name == 'main':

model = LSTM(50, 100, 2,batch_first=True)

x = Variable(Tensor(32,50, 50))

h = model.init_hidden(32)

print(model(x, h))`

and it will return :

`Traceback (most recent call last):'

'File "lstm.py", line 379, in '

' print(model(x, h))'

' File "Python\Python35\lib\site-packages\torch\nn\modules\module.py", line 489, in call'

' result = self.forward(*input, **kwargs)'

' File "lstm.py", line 92, in forward'

' f_x, f_h = self.layer_forward(l, x, h, image_emb)'

' File "lstm.py", line 72, in layer_forward'

' y, h = l(x, h, image_emb)'

' File "Python\Python35\lib\site-packages\torch\nn\modules\module.py", line 489, in call'

' result = self.forward(*input, **kwargs)'

' File "lstm.py", line 336, in forward'

' preact = i2h + h2h'

'RuntimeError: The size of tensor a (50) must match the size of tensor b (32) at non-singleton dimension 0`

GuanlinLee avatar Jun 20 '19 07:06 GuanlinLee