size mismatch for model.encoder_embed_tokens.weight: copying a param with shape torch.Size([62, 256]) from checkpoint, the shape in current model is torch.Size([57, 256]).

See original GitHub issue

Having successfully run step 1, data preparation, I am now trying to run inference. I am using the given dataset preview. Running CUDA_VISIBLE_DEVICES=0 python tasks/run.py --config usr/configs/popcs_fs2.yaml --exp_name popcs_fs2_pmf0_1230 --reset --infer according to the readme.md, I end up with this error:

| model Trainable Parameters: 24.253M
Traceback (most recent call last):
  File "tasks/run.py", line 15, in <module>
    run_task()
  File "tasks/run.py", line 10, in run_task
    task_cls.start()
  File "/.../DiffSinger/tasks/base_task.py", line 258, in start
    trainer.test(task)
  File "/.../DiffSinger/utils/pl_utils.py", line 586, in test
    self.fit(model)
  File "/.../DiffSinger/utils/pl_utils.py", line 489, in fit
    self.run_pretrain_routine(model)
  File "/.../DiffSinger/utils/pl_utils.py", line 541, in run_pretrain_routine
    self.restore_weights(model)
  File "/.../DiffSinger/utils/pl_utils.py", line 617, in restore_weights
    self.restore_state_if_checkpoint_exists(model)
  File "/.../DiffSinger/utils/pl_utils.py", line 655, in restore_state_if_checkpoint_exists
    self.restore(last_ckpt_path, self.on_gpu)
  File "/.../DiffSinger/utils/pl_utils.py", line 668, in restore
    model.load_state_dict(checkpoint['state_dict'], strict=False)
  File "/.../envs/DiffSinger/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1223, in load_state_dict
    raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for FastSpeech2Task:
	size mismatch for model.encoder_embed_tokens.weight: copying a param with shape torch.Size([62, 256]) from checkpoint, the shape in current model is torch.Size([57, 256]).
	size mismatch for model.encoder.embed_tokens.weight: copying a param with shape torch.Size([62, 256]) from checkpoint, the shape in current model is torch.Size([57, 256]).

Do you have any ideas on what could be wrong here and how to resolve it?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
michaellin99999commented, Oct 3, 2022

Don’t use “dataset preview” to run the experiments. The “phone_set” generated from “dataset preview” is smaller than the “phone_set” generated from the whole dataset. (In your case: 57 vs. 62)

can you explain how to fix this issue if you trained the model with another dataset ended up with more phone set?

0reactions
Wayne-wonderaicommented, Sep 28, 2022

Hello, I have same issue as I try to use another english dataset. And I’m wondering why Inference from packed test set can work? (CUDA_VISIBLE_DEVICES=0 python tasks/run.py --config usr/configs/midi/e2e/opencpop/ds100_adj_rel.yaml --exp_name $MY_DS_EXP_NAME --reset --infer)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tensor size mismatch - PyTorch Forums
Size([28]) from checkpoint, where the shape is torch.Size([64]) in current model. size mismatch for features.3.squeeze.weight: copying a ...
Read more >
Size Mismatch Runtime Error When Trying to Load a PyTorch ...
weight : copying a param with shape torch.Size([400, 1024]) from checkpoint, the shape in current model is torch.Size([ ...
Read more >
RuntimeError: Error(s) in loading state_dict for DynamicUnet
12.0.weight: copying a param with shape torch.Size([3, 99, 1, 1]) from checkpoint, the shape in current model is torch.
Read more >
runwayml/stable-diffusion-inpainting - Hugging Face
size mismatch for model.diffusion_model.input_blocks.0.0.weight: copying a param with shape torch.Size([320, 9, 3, 3]) from checkpoint, ...
Read more >
Size mismatch for decoder.stopnet.1.linear_layer.weight
stopnet.1.linear_layer.weight: copying a param with shape torch.Size([1, 1584]) from checkpoint, the shape in current model is torch.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found