所以我正在尝试使用以下方法加载模型:
learn = create_cnn(data, models.resnet50, lin_ftrs=[2048], metrics=accuracy)
learn.clip_grad();
learn.load(f'{name}-stage-2.1')
但我收到以下错误
RuntimeError: Error(s) in loading state_dict for Sequential:
size mismatch for 1.8.weight: copying a param with shape torch.Size([5004, 2048]) from checkpoint, the shape in current model is torch.Size([4542, 2048]).
size mismatch for 1.8.bias: copying a param with shape torch.Size([5004]) from checkpoint, the shape in current model is torch.Size([4542]).
唯一不同的是我添加了一个stage-2.1
模型中不存在的随机验证拆分,当我删除拆分并且没有验证集时,因为stage-2.1
训练一切顺利。
发生了什么?