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

The model and loaded state dict do not match exactly #26

Open
puyiwen opened this issue Aug 17, 2022 · 3 comments
Open

The model and loaded state dict do not match exactly #26

puyiwen opened this issue Aug 17, 2022 · 3 comments

Comments

@puyiwen
Copy link

puyiwen commented Aug 17, 2022

Hi,I change the input size as 224x224,and I get a message 'the model and loaded state dict do not match exactly',the code still works.However,I'm not sure if the mit_b4 pre-trained model has already loaded.Can you help me?And I want to know,have you ever done an experiment which input size as 224x224.If you have done the experiment,can you tell me the corresponding evaluation index ?Thank you very much!!

@premchedella
Copy link

I am also getting the following error, I didn't change the input size.

load checkpoint from local path: ./code/models/weights/mit_b4.pth
The model and loaded state dict do not match exactly

unexpected key in source state_dict: head.weight, head.bias

Let me know how to resolve the this.

@puyiwen
Copy link
Author

puyiwen commented Dec 7, 2022

I am also getting the following error, I didn't change the input size.

load checkpoint from local path: ./code/models/weights/mit_b4.pth
The model and loaded state dict do not match exactly

unexpected key in source state_dict: head.weight, head.bias

Let me know how to resolve the this.

may be you should set the strict = False, like model.load_state_dict(torch.load(path),strict=False)

@premchedella
Copy link

thanks, let me look into this

I made a change incode\models\model.py

load_checkpoint(self.encoder, ckpt_path, logger=None)
to
load_checkpoint(self.encoder, ckpt_path, strict=False, logger=None)

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