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

RuntimeError: size mismatch (when using -brnn option) #4

Closed
irshadbhat opened this issue Feb 27, 2017 · 3 comments
Closed

RuntimeError: size mismatch (when using -brnn option) #4

irshadbhat opened this issue Feb 27, 2017 · 3 comments

Comments

@irshadbhat
Copy link
Contributor

irshadbhat commented Feb 27, 2017

When I train a model with default parameters and translate with translate.py it works fine. When I use the brnn option for training, the train code works fine but the translate.py throws a RuntimeError: size mismatch. Please help me out if I am doing anything wrong. These are the codes that I executed:

python preprocess.py -train_src data/src-train.txt -train_tgt data/trg-train.txt -valid_src data/src-val.txt -valid_tgt data/trg-val.txt -save_data data/ehtrans

python train.py -data data/ehtrans-train.pt -save_model eh/model -brnn -brnn_merge concat -epochs 1000 -cuda

python translate.py -model eh/model_e7_13.28.pt -src data/src-val.txt -tgt data/trg-val.txt -output file-tgt.tok -cuda

The preprocess and train codes work fine but the translate code throws the following error:

Traceback (most recent call last):
  File "translate.py", line 121, in <module>
    main()
  File "translate.py", line 74, in main
    predBatch, predScore, goldScore = translator.translate(srcBatch, tgtBatch)
  File "/DATA/USERS/irshad/OpenNMT-py/onmt/Translator.py", line 190, in translate
    pred, predScore, attn, goldScore = self.translateBatch(batch)
  File "/DATA/USERS/irshad/OpenNMT-py/onmt/Translator.py", line 87, in translateBatch
    tgtBatch[:-1], decStates, context, initOutput)
  File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 202, in __call__
    result = self.forward(*input, **kwargs)
  File "/DATA/USERS/irshad/OpenNMT-py/onmt/Models.py", line 119, in forward
    output, hidden = self.rnn(emb_t, hidden)
  File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 202, in __call__
    result = self.forward(*input, **kwargs)
  File "/DATA/USERS/irshad/OpenNMT-py/onmt/Models.py", line 61, in forward
    h_1_i, c_1_i = layer(input, (h_0[i], c_0[i]))
  File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 202, in __call__
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/rnn.py", line 472, in forward
    self.bias_ih, self.bias_hh,
  File "/usr/local/lib/python2.7/dist-packages/torch/nn/_functions/rnn.py", line 22, in LSTMCell
    gates = F.linear(input, w_ih, b_ih) + F.linear(hx, w_hh, b_hh)
  File "/usr/local/lib/python2.7/dist-packages/torch/nn/functional.py", line 381, in linear
    return bias and state(input, weight, bias) or state(input, weight)
  File "/usr/local/lib/python2.7/dist-packages/torch/nn/_functions/linear.py", line 10, in forward
    output.addmm_(0, 1, input, weight.t())
RuntimeError: size mismatch, m1: [30 x 250], m2: [500 x 2000] at /home/soumith/local/builder/wheel/pytorch-src/torch/lib/TH/generic/THTensorMath.c:862
@irshadbhat irshadbhat changed the title RuntimeError: size mismatch RuntimeError: size mismatch (when using -brnn option) Feb 27, 2017
@beichao1314
Copy link

I test it and work well, maybe you can update the OpenNMT-py

@guillaumekln
Copy link
Contributor

I'm unable to reproduce it as well. Update the project and let us know if the issue persists.

@irshadbhat
Copy link
Contributor Author

Updated and works fine for me as well.

HendrikStrobelt pushed a commit to HendrikStrobelt/OpenNMT-py that referenced this issue Mar 17, 2018
srush pushed a commit that referenced this issue Jun 26, 2018
Make comments compatible with doc format
Gldkslfmsd pushed a commit to Gldkslfmsd/OpenNMT-py that referenced this issue Sep 6, 2018
added sample command for training multi-encoder model with multi30k data
saikat107 pushed a commit to saikat107/OpenNMT-py that referenced this issue Mar 12, 2019
avaucher referenced this issue in rxn4chemistry/OpenNMT-py Jun 17, 2022
Option to set the number of threads for translation
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

3 participants