gau820827 / AI-writer_Data2Doc

PyTorch Implementation of NBA game summary generator.
Apache License 2.0
83 stars 22 forks source link

TypeError: forward() takes 3 positional arguments but 5 were given #54

Open scut-salmon opened 6 years ago

scut-salmon commented 6 years ago

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

novegetate commented 5 years ago

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

Yonggie commented 5 years ago

man, you gotta post your code, not just the error itself.

BlackFeetMouse commented 4 years ago

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.

BlackFeetMouse commented 4 years ago

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.