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 ModuleList #10

Open
prershen opened this issue Dec 18, 2020 · 1 comment
Open

Error(s) in loading state_dict for ModuleList #10

prershen opened this issue Dec 18, 2020 · 1 comment

Comments

@prershen
Copy link

I was training with Cityscapes dataset and I trained and saved the weights with no changes to your code. But when Im loading it in eval.py it is giving the following error.

Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/content/gdrive/MyDrive/SReC-master/src/eval.py", line 121, in
main()
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 829, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/content/gdrive/MyDrive/SReC-master/src/eval.py", line 95, in main
compressor.nets.load_state_dict(checkpoint["nets"])
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 845, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for ModuleList:
Missing key(s) in state_dict: "1.0.rgb_decs.0.body.3.weight", "1.0.rgb_decs.0.body.3.bias", "1.0.rgb_decs.1.body.3.weight", "1.0.rgb_decs.1.body.3.bias", "1.0.rgb_decs.2.body.3.weight", "1.0.rgb_decs.2.body.3.bias", "1.1.rgb_decs.0.body.3.weight", "1.1.rgb_decs.0.body.3.bias", "1.1.rgb_decs.1.body.3.weight", "1.1.rgb_decs.1.body.3.bias", "1.1.rgb_decs.2.body.3.weight", "1.1.rgb_decs.2.body.3.bias", "1.2.rgb_decs.0.body.3.weight", "1.2.rgb_decs.0.body.3.bias", "1.2.rgb_decs.1.body.3.weight", "1.2.rgb_decs.1.body.3.bias", "1.2.rgb_decs.2.body.3.weight", "1.2.rgb_decs.2.body.3.bias".
Unexpected key(s) in state_dict: "1.0.rgb_decs.0.body.4.body.0.weight", "1.0.rgb_decs.0.body.4.body.0.bias", "1.0.rgb_decs.0.body.4.body.2.weight", "1.0.rgb_decs.0.body.4.body.2.bias", "1.0.rgb_decs.0.body.5.weight", "1.0.rgb_decs.0.body.5.bias", "1.0.rgb_decs.0.body.3.body.0.weight", "1.0.rgb_decs.0.body.3.body.0.bias", "1.0.rgb_decs.0.body.3.body.2.weight", "1.0.rgb_decs.0.body.3.body.2.bias", "1.0.rgb_decs.1.body.4.body.0.weight", "1.0.rgb_decs.1.body.4.body.0.bias", "1.0.rgb_decs.1.body.4.body.2.weight", "1.0.rgb_decs.1.body.4.body.2.bias", "1.0.rgb_decs.1.body.5.weight", "1.0.rgb_decs.1.body.5.bias", "1.0.rgb_decs.1.body.3.body.0.weight", "1.0.rgb_decs.1.body.3.body.0.bias", "1.0.rgb_decs.1.body.3.body.2.weight", "1.0.rgb_decs.1.body.3.body.2.bias", "1.0.rgb_decs.2.body.4.body.0.weight", "1.0.rgb_decs.2.body.4.body.0.bias", "1.0.rgb_decs.2.body.4.body.2.weight", "1.0.rgb_decs.2.body.4.body.2.bias", "1.0.rgb_decs.2.body.5.weight", "1.0.rgb_decs.2.body.5.bias", "1.0.rgb_decs.2.body.3.body.0.weight", "1.0.rgb_decs.2.body.3.body.0.bias", "1.0.rgb_decs.2.body.3.body.2.weight", "1.0.rgb_decs.2.body.3.body.2.bias", "1.1.rgb_decs.0.body.4.body.0.weight", "1.1.rgb_decs.0.body.4.body.0.bias", "1.1.rgb_decs.0.body.4.body.2.weight", "1.1.rgb_decs.0.body.4.body.2.bias", "1.1.rgb_decs.0.body.5.weight", "1.1.rgb_decs.0.body.5.bias", "1.1.rgb_decs.0.body.3.body.0.weight", "1.1.rgb_decs.0.body.3.body.0.bias", "1.1.rgb_decs.0.body.3.body.2.weight", "1.1.rgb_decs.0.body.3.body.2.bias", "1.1.rgb_decs.1.body.4.body.0.weight", "1.1.rgb_decs.1.body.4.body.0.bias", "1.1.rgb_decs.1.body.4.body.2.weight", "1.1.rgb_decs.1.body.4.body.2.bias", "1.1.rgb_decs.1.body.5.weight", "1.1.rgb_decs.1.body.5.bias", "1.1.rgb_decs.1.body.3.body.0.weight", "1.1.rgb_decs.1.body.3.body.0.bias", "1.1.rgb_decs.1.body.3.body.2.weight", "1.1.rgb_decs.1.body.3.body.2.bias", "1.1.rgb_decs.2.body.4.body.0.weight", "1.1.rgb_decs.2.body.4.body.0.bias", "1.1.rgb_decs.2.body.4.body.2.weight", "1.1.rgb_decs.2.body.4.body.2.bias", "1.1.rgb_decs.2.body.5.weight", "1.1.rgb_decs.2.body.5.bias", "1.1.rgb_decs.2.body.3.body.0.weight", "1.1.rgb_decs.2.body.3.body.0.bias", "1.1.rgb_decs.2.body.3.body.2.weight", "1.1.rgb_decs.2.body.3.body.2.bias", "1.2.rgb_decs.0.body.4.body.0.weight", "1.2.rgb_decs.0.body.4.body.0.bias", "1.2.rgb_decs.0.body.4.body.2.weight", "1.2.rgb_decs.0.body.4.body.2.bias", "1.2.rgb_decs.0.body.5.weight", "1.2.rgb_decs.0.body.5.bias", "1.2.rgb_decs.0.body.3.body.0.weight", "1.2.rgb_decs.0.body.3.body.0.bias", "1.2.rgb_decs.0.body.3.body.2.weight", "1.2.rgb_decs.0.body.3.body.2.bias", "1.2.rgb_decs.1.body.4.body.0.weight", "1.2.rgb_decs.1.body.4.body.0.bias", "1.2.rgb_decs.1.body.4.body.2.weight", "1.2.rgb_decs.1.body.4.body.2.bias", "1.2.rgb_decs.1.body.5.weight", "1.2.rgb_decs.1.body.5.bias", "1.2.rgb_decs.1.body.3.body.0.weight", "1.2.rgb_decs.1.body.3.body.0.bias", "1.2.rgb_decs.1.body.3.body.2.weight", "1.2.rgb_decs.1.body.3.body.2.bias", "1.2.rgb_decs.2.body.4.body.0.weight", "1.2.rgb_decs.2.body.4.body.0.bias", "1.2.rgb_decs.2.body.4.body.2.weight", "1.2.rgb_decs.2.body.4.body.2.bias", "1.2.rgb_decs.2.body.5.weight", "1.2.rgb_decs.2.body.5.bias", "1.2.rgb_decs.2.body.3.body.0.weight", "1.2.rgb_decs.2.body.3.body.0.bias", "1.2.rgb_decs.2.body.3.body.2.weight", "1.2.rgb_decs.2.body.3.body.2.bias"

Please help me resolve this.

@RowlingJ
Copy link

RowlingJ commented Jun 3, 2024

I ran into the same problem, checked and found that
in train.py
"""
@click.option("--resblocks", type=int, default=5, show_default=True,
help="Number of resblocks to use.")
"""
in eval.py
"""
@click.option("--resblocks", type=int, default=3, show_default=True,
help="Number of resblocks to use.")
"""
These two values should be set to the same

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