class Model(nn.Module):
def __init__(self):
super().__init__()
def forward(self,x):
m=nn.LSTMCell(x.shape[1],x.shape[1]*2)
output,_=m(x)
dense=nn.Linear(output.shape[1],1)
Your current code snippet recreates the nn.LSTMCell
and nn.Linear
modules in each forward pass randomly and doesn’t register them.
The proper way is to initialize submodules in the __init__
method and use them in the forward
.