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

官方模型权重怎样在非imagenet数据集上继续运行? #244

Open
newman012 opened this issue Mar 18, 2024 · 4 comments
Open

官方模型权重怎样在非imagenet数据集上继续运行? #244

newman012 opened this issue Mar 18, 2024 · 4 comments

Comments

@newman012
Copy link

您好,我使用官方的pvig_s_82.1.pth.tar权重去训练我自己的数据集(67个类别)时,出现DeepGCN最后一层维度不匹配的情况:
RuntimeError: Error(s) in loading state_dict for DeepGCN:
size mismatch for prediction.4.weight: copying a param with shape torch.Size([1000, 1024, 1, 1]) from checkpoint, the shape in current model is torch.Size([67, 1024, 1, 1]).
size mismatch for prediction.4.bias: copying a param with shape torch.Size([1000]) from checkpoint, the shape in current model is torch.Size([67]).
请问应该在哪里修改以适应我的数据集?

@iamhankai
Copy link
Member

最后一层prediction的输出类别改一下,原来是1000,改成67

@newman012
Copy link
Author

最后一层prediction的输出类别改一下,原来是1000,改成67

感谢答复!我看到prediction中最后的卷积层是(1024,numclasses),但我之前已经在命令行中指定了num-classes为67

@iamhankai
Copy link
Member

哦哦,看你的log报错,需要把pvig_s_82.1.pth.tar权重的prediction层权重去掉,再加载,不然size不match

@newman012
Copy link
Author

哦哦,看你的log报错,需要把pvig_s_82.1.pth.tar权重的prediction层权重去掉,再加载,不然size不match

谢谢,成功了。还有我想问下initial-checkpoint、resume、pretrain_ path这三者有何区别?我看都是加载模型权重的功能

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