Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win10+pytorch1.0 +py3.68+cuda10运行 RuntimeError: input must have 3 dimensions, got 4 #6

Open
QQ2737499951 opened this issue May 29, 2019 · 0 comments

Comments

@QQ2737499951
Copy link

QQ2737499951 commented May 29, 2019

"D:\Program Files\Python368\python.exe" B:/PyTorch/CaptchaRecognition/main.py
val_count= 1250
Loading data... 100_60_4_captcha.npz
Loading dictionary... [[ 0 3 3 4 12 11]
[ 0 4 7 7 1 12]
[ 0 8 5 4 12 11]
...
[ 0 8 3 9 6 12]
[ 0 4 2 6 12 11]
[ 0 8 9 8 8 12]]
vocab {'id2token': {1: '0', 2: '1', 3: '2', 4: '3', 5: '4', 6: '5', 7: '6', 8: '7', 9: '8', 10: '9', 11: ' ', 0: '^', 12: '$'}, 'token2id': {'0': 1, '1': 2, '2': 3, '3': 4, '4': 5, '5': 6, '6': 7, '7': 8, '8': 9, '9': 10, ' ': 11, '^': 0, '$': 12}}
Convert to tensor... total_size= None test_size= 8192
Build dataset...分离train+test
Build dataloader...载入train+test
data ready!
Traceback (most recent call last):
File "B:/PyTorch/CaptchaRecognition/main.py", line 86, in
criterion,CLIP,use_cuda=USE_CUDA)
File "B:\PyTorch\CaptchaRecognition\model.py", line 230, in train
encoder_outputs,encoder_hidden = encoder(inputs,init_hidden)
File "D:\Program Files\Python368\lib\site-packages\torch\nn\modules\module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "B:\PyTorch\CaptchaRecognition\model.py", line 47, in forward
out,hidden = self.gru(out,h0)
File "D:\Program Files\Python368\lib\site-packages\torch\nn\modules\module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "D:\Program Files\Python368\lib\site-packages\torch\nn\modules\rnn.py", line 207, in forward
self.check_forward_args(input, hx, batch_sizes)
File "D:\Program Files\Python368\lib\site-packages\torch\nn\modules\rnn.py", line 175, in check_forward_args
self.check_input(input, batch_sizes)
File "D:\Program Files\Python368\lib\site-packages\torch\nn\modules\rnn.py", line 149, in check_input
expected_input_dim, input.dim()))
### RuntimeError: input must have 3 dimensions, got 4

这个源码之前在0.4版我运行过没问题的,前几天刚升级到pytorch 1.0 、pytorch 1.1都不行,谢谢楼主!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant