huawei-noah / Efficient-AI-Backbones

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

关于加载g_ghost_regnetx_032预训练权重的问题 #282

Open linyu17 opened 1 week ago

linyu17 commented 1 week ago

您好,我在使用g_ghost_regnetx_032作为特征提取网络训练自己的分类任务时,我想加载预训练模型g_ghost_regnet_3.2g_77.8.pth,使用到的代码如下:

import torch from models.g_ghost_renet import g_ghost_regnetx_032 model = g_ghost_regnetx_032() model.load_state_dict(torch.load('./weights/g_ghost_regnet_3.2g_77.8.pth')) print(model)

出现了如下报错: RuntimeError: Error(s) in loading state_dict for GGhostRegNet: Missing key(s) in state_dict: "conv1.weight", "bn1.weight", "bn1.bias", "bn1.running_mean", "bn1.running_var", "layer1.0.conv1.weight", "layer1.0.bn1.weight", "layer1.0.bn1.bias", "layer1.0.bn1.running_mean", "layer1.0.bn1.running_var", 。。。。。 Unexpected key(s) in state_dict: "module.conv1.weight", "module.bn1.weight", "module.bn1.bias", "module.bn1.running_mean", "module.bn1.

请问这是不是因为pytorch版本不匹配的问题,我需要如何才能使用到预训练模型呢,期待您的回复!