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

加载权重sparseformer_t_imagenet1k.pth进行测试时(test_main.py)报错: #5

Open
wukunkkkk opened this issue May 21, 2024 · 1 comment

Comments

@wukunkkkk
Copy link

RuntimeError: Error(s) in loading state_dict for SparseFormer:
Missing key(s) in state_dict: "norm.weight", "norm.bias", "proj.weight", "proj.bias".
Unexpected key(s) in state_dict: "head.norm.weight", "head.norm.bias", "head.classifier.weight", "head.classifier.bias"

@sebgao
Copy link
Collaborator

sebgao commented May 21, 2024

Hi, the usage in test_main.py is outdated. We recommend using create_model in README.md to create the model:

from sparseformer.factory import create_model
model = create_model("sparseformer_v1_tiny", download=True)

If you prefer to stick to this way, you can rename the keys in the state dict as the error message says

head.norm.weight -> norm.weight
head.norm.bias -> norm.bias
head.classifier.weight -> proj.weight
head.classifier.bias -> proj.bias

Will update soon.

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