I have the following code:
import torch
import torch.nn as nn
model = nn.Sequential(
nn.LSTM(300, 300),
nn.Linear(300, 100),
nn.ReLU(),
nn.Linear(300, 7),
)
s = torch.ones(1, 50, 300)
a = model(s)
And I get:
My-MBP:Desktop myname$ python3 testmodel.py
Traceback (most recent call last):
File "testmodel.py", line 12, in <module>
a = model(s)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torch/nn/modules/container.py", line 117, in forward
input = module(input)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torch/nn/modules/linear.py", line 93, in forward
return F.linear(input, self.weight, self.bias)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torch/nn/functional.py", line 1688, in linear
if input.dim() == 2 and bias is not None:
AttributeError: 'tuple' object has no attribute 'dim'
Why? The dimensions should be fine. I saw related fixes to this issue when *input
is defined in model.forward
, but I don't even have anything implemented yet.
/edit: WAIT, there IS a *input
!? How can I override this?