I use Alexnet to estimate the angle of a persons head in 3D in Realtime (e.g. Person in front of Camera). I want to improve this estimation by using an RNN. This should improve the estimation, because the frames are sequential. (Hope this is the right word. My english is not so good as you probrably noticed  )
First i implemented alexnet normally. But now I’m trying to replace all 3  Linear Layers in “classifier” (see above) with RNN Layers.
Because I’m using a Pretrained Alexnet I need to change the Layers after loading the model. I’m allready did this to simplify the output to only the 3 angles. ( model.classifier._modules[‘6’] = nn.Linear(4096, 3) )
I now changed all 3 Layers to RNNs
model.classifier._modules[‘1’] = nn.RNN(256 * 6 * 6, 4096, batch_first=True)
model.classifier._modules[‘4’] = nn.RNN(4096, 4096, batch_first=True)
model.classifier._modules[‘6’] = nn.RNN(4096, 3, batch_first=True)
(I know these Layers are now not pretrained any more. I still have to figure out how to copy the pretrained weights to the right spots)
If i understand it right, i need batch_first because of my  [32, 3, 244, 244] Inputtensor. 32 is Batchsize, and 3,244,244 is the frame
I also modified out = model(input) to out, hidden = model(input, hidden). I set hidden = None for the first batch.
And now I get this error:
Traceback (most recent call last):
File “/home/jan/anaconda3/envs/TensorboardX/lib/python3.6/threading.py”, line 916, in _bootstrap_inner
self.run()
File “/home/jan/anaconda3/envs/TensorboardX/lib/python3.6/threading.py”, line 864, in run
self._target(*self._args, **self._kwargs)
File “/home/jan/PycharmProjects/Bachelor-Kopfposenschaetzung/AlexRNN.py”, line 221, in train
out, hidden = model(input, hidden)
File “/home/jan/anaconda3/envs/TensorboardX/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 491, in call
result = self.forward(*input, **kwargs)
TypeError: forward() takes 2 positional arguments but 3 were given
Is my Input in a wrong shape? @klory wrote, that I need an Input of shape (seq_len, batch, input_size), but I actually don’t know how this means. Is this the my input in the line out, hidden = model(input, hidden) or is a different input meant?
Hope It is understandable what my Problem is. Thanks