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

got error when I run your code. #3

Open
carlhung opened this issue Dec 1, 2017 · 1 comment
Open

got error when I run your code. #3

carlhung opened this issue Dec 1, 2017 · 1 comment

Comments

@carlhung
Copy link

carlhung commented Dec 1, 2017

Reading lines...
Read 141382 sentence pairs
Trimmed to 11132 sentence pairs
Counting words...
Counted words:
eng 2953
fra 4540
start training...
Traceback (most recent call last):
File "train.py", line 186, in
main()
File "train.py", line 181, in main
train(pair_data_loader, encoder1, attn_decoder1, 75000)
File "train.py", line 100, in train
decoder, encoder_optimizer, decoder_optimizer, criterion)
File "train.py", line 52, in train_model
loss += criterion(decoder_output[0], target_variable[di])
File "/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 224, in call
result = self.forward(*input, **kwargs)
File "/anaconda3/lib/python3.6/site-packages/torch/nn/modules/loss.py", line 132, in forward
self.ignore_index)
File "/anaconda3/lib/python3.6/site-packages/torch/nn/functional.py", line 676, in nll_loss
raise ValueError('Expected 2 or 4 dimensions (got {})'.format(dim))
ValueError: Expected 2 or 4 dimensions (got 1)

@siliconberry
Copy link

same here as well.

Traceback (most recent call last):
File "train.py", line 186, in
main()
File "train.py", line 181, in main
train(pair_data_loader, encoder1, attn_decoder1, 75000)
File "train.py", line 100, in train
decoder, encoder_optimizer, decoder_optimizer, criterion)
File "train.py", line 69, in train_model
loss += criterion(decoder_output[0], target_variable[di])
File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 357, in call
result = self.forward(*input, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/loss.py", line 170, in forward
self.ignore_index, self.reduce)
File "/usr/local/lib/python3.5/dist-packages/torch/nn/functional.py", line 1069, in nll_loss
raise ValueError('Expected 2 or more dimensions (got {})'.format(dim))
ValueError: Expected 2 or more dimensions (got 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

2 participants