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

Weights dimensions mismatch when loading a saved .pth: d_con1_lin_src.weight #8

Open
usmancheema89 opened this issue Feb 2, 2024 · 1 comment

Comments

@usmancheema89
Copy link

Steps to reproduce:

  • train model with default configuration one the given dataset (train.py)
  • load saved model for testing (test.py)

Exception trace:

cd /home/usman/Work/GlobalMapper ; /usr/bin/env /home/usman/anaconda3/envs/SD201/bin/python /home/usman/.vscode-server/extensions/ms-python.debugpy-2024.0.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 47893 -- /home/usman/Work/GlobalMapper/test.py
/home/usman/Work/GlobalMapper/model.py:129: UserWarning: nn.init.xavier_uniform is now deprecated in favor of nn.init.xavier_uniform_.
m.weight.data = nn.init.xavier_uniform(m.weight.data, gain=nn.init.calculate_gain('relu'))
/home/usman/Work/GlobalMapper/model.py:394: UserWarning: nn.init.xavier_uniform is now deprecated in favor of nn.init.xavier_uniform_.
m.weight.data = nn.init.xavier_uniform(m.weight.data, gain=nn.init.calculate_gain('relu'))
Traceback (most recent call last):
File "/home/usman/anaconda3/envs/SD201/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/home/usman/anaconda3/envs/SD201/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/usman/.vscode-server/extensions/ms-python.debugpy-2024.0.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/main.py", line 39, in
cli.main()
File "/home/usman/.vscode-server/extensions/ms-python.debugpy-2024.0.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main
run()
File "/home/usman/.vscode-server/extensions/ms-python.debugpy-2024.0.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file
runpy.run_path(target, run_name="main")
File "/home/usman/.vscode-server/extensions/ms-python.debugpy-2024.0.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321, in run_path
return _run_module_code(code, init_globals, run_name,
File "/home/usman/.vscode-server/extensions/ms-python.debugpy-2024.0.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/home/usman/.vscode-server/extensions/ms-python.debugpy-2024.0.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
exec(code, run_globals)
File "/home/usman/Work/GlobalMapper/test.py", line 132, in
model.load_state_dict(torch.load(os.path.join(test_yaml, pth_name + ".pth"), map_location=device), strict=False)
File "/home/usman/anaconda3/envs/SD201/lib/python3.10/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 AttentionBlockGenerator_independent_cnn:
While copying the parameter named "d_conv1.lin_src.weight", whose dimensions in the model are torch.Size([0]) and whose dimensions in the checkpoint are torch.Size([3072, 376]), an exception occurred : ('The size of tensor a (0) must match the size of tensor b (376) at non-singleton dimension 1',).

@Arking1995
Copy link
Owner

I suppose that is mostly the pytorch geometric version issue. If you do use the newer version than readme says, update the definition codes for graph attention layer will be helpful. Thanks for the feedbacks!

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