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

Error(s) in loading state_dict for TransformerModel: #3

Open
Nimishasri opened this issue Aug 12, 2020 · 3 comments
Open

Error(s) in loading state_dict for TransformerModel: #3

Nimishasri opened this issue Aug 12, 2020 · 3 comments

Comments

@Nimishasri
Copy link

Nimishasri commented Aug 12, 2020

downloaded all the models (mm-all was commented out in scripts/download-and-setup-models.sh).
Ran the test translation script as mentioned in the Readme.

Error(s) in loading state_dict for TransformerModel:
	size mismatch for encoder.embed_tokens.weight: copying a param with shape torch.Size([28168, 512]) from checkpoint, the shape in current model is torch.Size([26346, 512]).
	size mismatch for decoder.embed_out: copying a param with shape torch.Size([28160, 512]) from checkpoint, the shape in current model is torch.Size([26346, 512]).
	size mismatch for decoder.embed_tokens.weight: copying a param with shape torch.Size([28160, 512]) from checkpoint, the shape in current model is torch.Size([26346, 512]).
@jerinphilip
Copy link
Owner

This is weird, it should work. Maybe some fairseq-padding option. Try to use the more recent ones.

    "mm-all-iter0"
    "mm-all-iter1"
    "mm-to-en-iter1"

@Nimishasri
Copy link
Author

Nimishasri commented Aug 12, 2020

Error on Gogle colab , invoking "mm-all-iter0"

| [src] dictionary: 40897 types
| [tgt] dictionary: 40897 types
/content/MyDrive/ColabNotebooks/ilmulti-master/ilmulti/translator/translator.py:23: UserWarning: utils.load_ensemble_for_inference is deprecated. Please use checkpoint_utils.load_model_ensemble instead.
  self.models, model_args = fairseq.utils.load_ensemble_for_inference(model_paths, self.task, model_arg_overrides=eval(args.model_overrides))
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-8-cba9eb6f9aca> in <module>()
      2 from ilmulti.translator import from_pretrained
      3 translator = from_pretrained(tag='mm-all-iter0')
----> 4 sample = translator('I am going', tgt_lang = 'hi')
      5 print(sample)

5 frames
/usr/local/lib/python3.6/dist-packages/fairseq/search.py in step(self, step, lprobs, scores)
     79             out=(self.scores_buf, self.indices_buf),
     80         )
---> 81         torch.div(self.indices_buf, vocab_size, out=self.beams_buf)
     82         self.indices_buf.fmod_(vocab_size)
     83         return self.scores_buf, self.indices_buf, self.beams_buf

RuntimeError: Integer division of tensors using div or / is no longer supported, and in a future release div will perform true division as in Python 3. Use true_divide or floor_divide (// in Python) instead.

@jerinphilip
Copy link
Owner

Check #1.
Why are you using colab? Switch the install to torch=1.0.0 at the start of the notebook, that should work. Before installing ilmulti <- fairseq-ilmt.

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