fairseq icon indicating copy to clipboard operation
fairseq copied to clipboard

Size mismatch error when running the paraphrase script

Open Nadiaghobadi opened this issue 5 years ago • 2 comments

Hi,

I'm trying to test the paraphrase code with En2Fr and Fr2En pre-trained models. I followed this:

git clone https://github.com/pytorch/fairseq.git
cd fairseq
pip install --editable .
pip install sacremoses sentencepiece

wget https://dl.fbaipublicfiles.com/fairseq/models/paraphraser.en-fr.tar.gz
wget https://dl.fbaipublicfiles.com/fairseq/models/paraphraser.fr-en.hMoEup.tar.gz
tar -xzvf paraphraser.en-fr.tar.gz
tar -xzvf paraphraser.fr-en.hMoEup.tar.gz

python examples/paraphraser/paraphrase.py \
    --en2fr paraphraser.en-fr \
    --fr2en paraphraser.fr-en.hMoEup

but I get this error:

INFO:root:loading fr2en model from:paraphraser.fr-en.hMoEup
INFO:fairseq.file_utils:loading archive file paraphraser.fr-en.hMoEup
INFO:fairseq.tasks.translation:[fr] dictionary: 40960 types
INFO:fairseq.tasks.translation:[en] dictionary: 40960 types
Traceback (most recent call last):
  File "examples/paraphraser/paraphrase.py", line 86, in <module>
    main()
  File "examples/paraphraser/paraphrase.py", line 66, in main
    task="translation",
  File "/Users/nadia/Desktop/GIT/fairseq/fairseq/models/fairseq_model.py", line 262, in from_pretrained
    **kwargs,
  File "/Users/nadia/Desktop/GIT/fairseq/fairseq/hub_utils.py", line 75, in from_pretrained
    arg_overrides=kwargs,
  File "/Users/nadia/Desktop/GIT/fairseq/fairseq/checkpoint_utils.py", line 324, in load_model_ensemble_and_task
    model.load_state_dict(state["model"], strict=strict, model_cfg=cfg.model)
  File "/Users/nadia/Desktop/GIT/fairseq/fairseq/models/fairseq_model.py", line 115, in load_state_dict
    return super().load_state_dict(new_state_dict, strict)
  File "/Users/nadia/opt/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1052, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for TransformerModel:
	size mismatch for encoder.embed_tokens.weight: copying a param with shape torch.Size([40970, 1024]) from checkpoint, the shape in current model is torch.Size([40960, 1024]).
	size mismatch for decoder.embed_tokens.weight: copying a param with shape torch.Size([40970, 1024]) from checkpoint, the shape in current model is torch.Size([40960, 1024]).
	size mismatch for decoder.output_projection.weight: copying a param with shape torch.Size([40970, 1024]) from checkpoint, the shape in current model is torch.Size([40960, 1024]).

Can you please help me with this?

Thanks!

Nadiaghobadi avatar Dec 30 '20 09:12 Nadiaghobadi

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

stale[bot] avatar Jul 21 '21 04:07 stale[bot]

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!

stale[bot] avatar May 02 '22 20:05 stale[bot]