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 SwinTransformer #37

Open
raphaelbourgade opened this issue Oct 11, 2023 · 3 comments
Open

Error(s) in loading state_dict for SwinTransformer #37

raphaelbourgade opened this issue Oct 11, 2023 · 3 comments

Comments

@raphaelbourgade
Copy link

Hello,

I've an error when I load the state dict for SwinTransformer (error I didn't have before)...

I do:

model = ctranspath()
model.head = nn.Identity()
td = torch.load(r'MY/PATH/ctranspath.pth')
model.load_state_dict(td['model'], strict=True)

And the error is :

"File ~\Documents\research\.myenv\Lib\site-packages\torch\nn\modules\module.py:2041, in Module.load_state_dict(self, state_dict, strict)
   2036         error_msgs.insert(
   2037             0, 'Missing key(s) in state_dict: {}. '.format(
   2038                 ', '.join('"{}"'.format(k) for k in missing_keys)))
   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 SwinTransformer:
	Missing key(s) in state_dict: "patch_embed.proj.weight", "patch_embed.proj.bias". 
	Unexpected key(s) in state_dict: "patch_embed.proj.0.weight", "patch_embed.proj.1.weight", "patch_embed.proj.1.bias", "patch_embed.proj.1.running_mean", "patch_embed.proj.1.running_var", "patch_embed.proj.1.num_batches_tracked", "patch_embed.proj.3.weight", "patch_embed.proj.4.weight", "patch_embed.proj.4.bias", "patch_embed.proj.4.running_mean", "patch_embed.proj.4.running_var", "patch_embed.proj.4.num_batches_tracked", "patch_embed.proj.6.weight", "patch_embed.proj.6.bias". "

Does anyone have the same problem?

@RunningStone
Copy link

same problem

@Xiyue-Wang
Copy link
Owner

please see here #34
image

@RunningStone
Copy link

solved, thank you

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

3 participants