AI-writer_Data2Doc
AI-writer_Data2Doc copied to clipboard
TypeError: forward() takes 3 positional arguments but 5 were given
When I try to predict the word using the model(BiLSTM) I generate by myself, it occurs the following error:
File "train.py", line 662, in predictwords encoder_hidden, encoder_hiddens = encoder(rt, re, rm, init_hidden) File "/home/zhangzhenchang/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in call result = self.forward(*input, **kwargs) TypeError: forward() takes 3 positional arguments but 5 were given
What's the function of "encoder" mean, how can I fix this problem. Thanks, Zhang
Traceback (most recent call last):
File "E:/audio data/AI-writer_Data2Doc-master/train/small_evaluate.py", line 52, in
man, you gotta post your code, not just the error itself.
Traceback (most recent call last): File "E:/audio data/AI-writer_Data2Doc-master/train/small_evaluate.py", line 52, in for idx, text in enumerate(text_generator): File "E:\audio data\AI-writer_Data2Doc-master\train\train.py", line 776, in evaluate beam_size) File "E:\audio data\AI-writer_Data2Doc-master\train\train.py", line 670, in predictwords out, encoder_hidden = encoder(rt, re, rm, encoder_hidden) File "D:\anaconda\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 477, in call result = self.forward(*input, **kwargs) TypeError: forward() takes 3 positional arguments but 5 were given
Hi Novegetate, have you solved the problem? I met the same issue. I am thinking whether it is because of the difference of pytorch's version.
I found the solution. You should combine rt
,re
, rm
into one dictionary inputs
like inputs = {'rt': rt, 're': re, 'rm': rm}
Then you only need input three arguments instead of five.