Open linyu17 opened 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版本不匹配的问题,我需要如何才能使用到预训练模型呢,期待您的回复!
您好,我在使用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版本不匹配的问题,我需要如何才能使用到预训练模型呢,期待您的回复!