huawei-noah / Efficient-AI-Backbones

Efficient AI Backbones including GhostNet, TNT and MLP, developed by Huawei Noah's Ark Lab.
4.05k stars 708 forks source link

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

Open newman012 opened 8 months ago

newman012 commented 8 months ago

您好,我使用官方的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 commented 8 months ago

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

newman012 commented 8 months ago

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

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

iamhankai commented 8 months ago

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

newman012 commented 8 months ago

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

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