Seanny123 / da-rnn

Dual-Stage Attention-Based Recurrent Neural Net for Time Series Prediction
333 stars 118 forks source link

I got an error when run main_predict.py after running main.py successful #13

Open gao27024037 opened 5 years ago

gao27024037 commented 5 years ago

![Uploading TIM截图20191010220050.png…]() Traceback (most recent call last): File "D:/graduate/Code/Research/DA_RNN/Seanny123/main_predict.py", line 74, in <module> final_y_pred = predict(enc, dec, data, **da_rnn_kwargs) File "D:/graduate/Code/Research/DA_RNN/Seanny123/main_predict.py", line 49, in predict y_pred[y_slc] = decoder(input_encoded, y_history).cpu().data.numpy() File "B:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 547, in __call__ result = self.forward(*input, **kwargs) File "D:\graduate\Code\Research\DA_RNN\Seanny123\modules.py", line 108, in forward y_tilde = self.fc(torch.cat((context, y_history[:, t]), dim=1)) # (batch_size, out_size) File "B:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 547, in __call__ result = self.forward(*input, **kwargs) File "B:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\linear.py", line 87, in forward return F.linear(input, self.weight, self.bias) File "B:\ProgramData\Anaconda3\lib\site-packages\torch\nn\functional.py", line 1369, in linear ret = torch.addmm(bias, input, weight.t()) RuntimeError: size mismatch, m1: [128 x 40624], m2: [65 x 1] at C:\w\1\s\tmp_conda_3.7_021303\conda\conda-bld\pytorch_1565316900252\work\aten\src\TH/generic/THTensorMath.cpp:752 I have read the similar issues #2 but there isn't "unsqueeze(1)" in the newest code. I have tried to add unsqueeze(1) back as same as the old location ( like Chandler Zuo did), but main.py and main_predict.py both cannot running rightly. Could someone tell me how can i solve it? Please

thank you

chuanchuan12138 commented 5 years ago

对比main和main_predict的predict函数,看里面的1和0对着改一下就好了。

Apogeum12 commented 4 years ago

Hey I have this same issue, how i can solve this ? I don't understand previous answer :( My error ###################################### Traceback (most recent call last):

File "", line 1, in runfile('C:/Users/jezus/Downloads/Sieci/Sars2020/Script_version/da-rnn-master/main_predict.py', wdir='C:/Users/jezus/Downloads/Sieci/Sars2020/Script_version/da-rnn-master')

File "C:\Users\jezus\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile execfile(filename, namespace)

File "C:\Users\jezus\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/jezus/Downloads/Sieci/Sars2020/Script_version/da-rnn-master/main_predict.py", line 74, in final_y_pred = predict(enc, dec, data, **da_rnn_kwargs)

File "C:/Users/jezus/Downloads/Sieci/Sars2020/Script_version/da-rnn-master/main_predict.py", line 49, in predict y_pred[y_slc] = decoder(input_encoded, y_history).cpu().data

File "C:\Users\jezus\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 541, in call result = self.forward(*input, **kwargs)

File "C:\Users\jezus\Downloads\Sieci\Sars2020\Script_version\da-rnn-master\modules.py", line 107, in forward y_tilde = self.fc(torch.cat((context, y_history[:, t]), dim=1)) # (batch_size, out_size)

File "C:\Users\jezus\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 541, in call result = self.forward(*input, **kwargs)

File "C:\Users\jezus\Anaconda3\lib\site-packages\torch\nn\modules\linear.py", line 87, in forward return F.linear(input, self.weight, self.bias)

File "C:\Users\jezus\Anaconda3\lib\site-packages\torch\nn\functional.py", line 1370, in linear ret = torch.addmm(bias, input, weight.t())

RuntimeError: size mismatch, m1: [128 x 40624], m2: [65 x 1] at C:/w/1/s/tmp_conda_3.7_104508/conda/conda-bld/pytorch_1572950778684/work/aten/src\THC/generic/THCTensorMathBlas.cu:290

###########################################################

Apogeum12 commented 4 years ago

Ok I solved this: In main_predict.py in function predict() change the shape from 0 to 1 in y_history t_dat.targs.shape[0] -> t_dat.targs.shape[1]