class MyResNeXt(models.resnet.ResNet):
def __init__(self, training=True):
super(MyResNeXt, self).__init__(block=models.resnet.Bottleneck,
layers=[3, 4, 6, 3],
groups=32,
width_per_group=4)
self.load_state_dict(checkpoint)
self.fc = nn.Linear(2048, 1)
model = MyResNeXt().to(gpu)
[k for k,v in model.named_parameters()]
freeze_until(model, "layer4.0.conv1.weight")
[k for k,v in model.named_parameters() if v.requires_grad]
Я пытался обучить ре-тексту с помощью трансферного обучения. Замораживаю какой-то слой и тренирую Затем я сохраняю модель
torch.save(model.state_dict(), path + f'resnext_fullv2.pth')
в этом случае модель сохраняет вес всей модели? или тренированный вес модели? Я получил ошибку "ошибка слоя не найдена"
untimeError: Ошибка (и) при загрузке state_dict для MyResNeXt: Отсутствие ключа (ей) в 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 "," layer1.0.conv2.weight "," layer1.0.bn2.weight "," layer1.0.bn2.bias "," layer1.0.bn2.running_mean "," layer1.0.bn2.running_var "," layer1.0.conv3.weight "," layer1.0.bn3.weight "," layer1.0.bn3.bias "," layer1.0.bn3.running_mean "," layer1.0.bn3.running_var "," layer1.0.downsample.0.weight "," layer1.0.downsample.1.weight "," layer1.0.downsample.1.bias "," layer1.0. downsample.1.running_mean "," layer1.0.downsample.1.running_var "," layer1.1.conv1.weight "," layer1.1.bn1.weight "," layer1.1.bn1.bias "," layer1.1.bn1.running_mean "," layer1.1.bn1.running_v