Skip to content

RuntimeError: Error(s) in loading state_dict for Decoder: Missing key(s) in state_dict when load a fine-tuned pth #121

@kingydw

Description

@kingydw

I'm new to model dev. when I follow the README built a env. I can run the inference demo well(both LJSpeech and Libri) and looks good done a fine-tune. It saving several pth file in the Model/LJSpeech path, like this

(base) [root@9fff32c6464a /styletts/Models/LJSpeech]# ll
total 13478048
-rw-r--r-- 1 1003 users       1896 Nov 30 16:44 config.yml
-rw-r--r-- 1 root root        1813 Nov 30 21:28 config_ft.yml
-rw-r--r-- 1 root root  2040174389 Nov 30 20:51 epoch_2nd_00004.pth
-rw-r--r-- 1 root root  2040174389 Nov 30 20:58 epoch_2nd_00009.pth
-rw-r--r-- 1 root root  2242831973 Nov 30 21:05 epoch_2nd_00014.pth
-rw-r--r-- 1 root root  2242831973 Nov 30 21:13 epoch_2nd_00019.pth
-rw-r--r-- 1 root root  2242831973 Nov 30 21:21 epoch_2nd_00024.pth
-rw-r--r-- 1 root root  2242831973 Nov 30 21:28 epoch_2nd_00029.pth
-rw-r--r-- 1 1003 users  749716474 Nov 30 15:44 epoch_2nd_00100.pth
drwxr-xr-x 2 root root        4096 Nov 30 20:43 tensorboard
-rw-r--r-- 1 root root       64176 Nov 30 21:28 train.log

in my opinion, after I got these new file, all I need is modify the load path pointer to one of the new pth file in Demo/Inference_LJSpeech.ipynb, like params_whole = torch.load("Models/LJSpeech/epoch_2nd_00029.pth", map_location='cpu') and re-run the Inference notebook can let me try the new fine-tuned model. but I got a RuntimeError below

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[11], line 5
      4 try:
----> 5     model[key].load_state_dict(params[key])
      6 except:

File /data/miniconda3/lib/python3.10/site-packages/torch/nn/modules/module.py:2041, in Module.load_state_dict(self, state_dict, strict)
   2040 if len(error_msgs) > 0:
-> 2041     raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
   2042                        self.__class__.__name__, "\n\t".join(error_msgs)))
   2043 return _IncompatibleKeys(missing_keys, unexpected_keys)

RuntimeError: Error(s) in loading state_dict for Decoder:
	Missing key(s) in state_dict: "decode.0.conv1.bias", "decode.0.conv1.weight_g", "decode.0.conv1.weight_v", "decode.0.conv2.bias", "decode.0.conv2.weight_g", "decode.0.conv2.weight_v", "decode.0.norm1.fc.weight", "decode.0.norm1.fc.bias", "decode.0.norm2.fc.weight", "decode.0.norm2.fc.bias", "decode.0.conv1x1.weight_g", "decode.0.conv1x1.weight_v", "decode.1.conv1.bias", "decode.1.conv1.weight_g", "decode.1.conv1.weight_v",
... # lots of missing keys output

my env is a docker on single A100

  • driver ver 470
  • cuda 1.17
  • torch 2.0.1

Can some help me what I missed? thanks a lot

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions