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

Mismatched weights running --test #124

Closed
bendoesai opened this issue Feb 4, 2025 · 2 comments
Closed

Mismatched weights running --test #124

bendoesai opened this issue Feb 4, 2025 · 2 comments

Comments

@bendoesai
Copy link

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Python311\Lib\site-packages\tmrl\__main__.py", line 88, in <module>
    main(arguments)
  File "C:\Python311\Lib\site-packages\tmrl\__main__.py", line 26, in main
    rw = RolloutWorker(env_cls=partial(GenericGymEnv, id=cfg.RTGYM_VERSION, gym_kwargs={"config": config}),
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\tmrl\networking.py", line 505, in __init__
    self.actor = self.actor.load(self.model_path, device=self.device)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\tmrl\actor.py", line 137, in load
    self.load_state_dict(torch.load(path, map_location=self.device))
  File "C:\Python311\Lib\site-packages\torch\nn\modules\module.py", line 2041, in load_state_dict
    raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for SquashedGaussianMLPActor:
        Missing key(s) in state_dict: "net.0.weight", "net.0.bias", "net.2.weight", "net.2.bias".
        Unexpected key(s) in state_dict: "net.conv1.weight", "net.conv1.bias", "net.conv2.weight", "net.conv2.bias", "net.conv3.weight", "net.conv3.bias", "net.conv4.weight", "net.conv4.bias", "net.mlp.0.weight", "net.mlp.0.bias", "net.mlp.2.weight", "net.mlp.2.bias".

Seems that the provided weights and the weights expected are a little different. Is this an issue that can be fixed in config or do I just need a new set of weights?

@yannbouteiller
Copy link
Member

yannbouteiller commented Feb 4, 2025

This is strange, none of the two neural networks embedded in tmrl have changed for years as far as I know.

Perhaps something changed in how Pytorch loads weights recently?

@bendoesai
Copy link
Author

Figured it out. my RUN_NAME and ENV settings were mismatched. I should have guessed that when unexpected keys were for conv layers. Until now I thought RUN_NAME was arbitrary and could be set to whatever.

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