How can I train using pth pretrained file? (For transfer learning)
Daehyun41 opened this issue · comments
I want to transfer learning using pth file (not tar file).
So, in retinaface.py 57 line
if cfg['name'] == 'mobilenet0.25':
backbone = MobileNetV1()
if cfg['pretrain']:
# checkpoint = torch.load("./weights/mobilenetV1X0.25_pretrain.tar", map_location=torch.device('cpu')) #pretrain path
checkpoint = torch.load("ete_DVS_70000_weights/mobilenet0.25mnet_epoch250_ete_style_70000.pth", map_location=torch.device('cpu')) # pretrain path
state_dict = checkpoint
from collections import OrderedDict
new_state_dict = OrderedDict()
# for k, v in checkpoint['state_dict'].items():
for k, v in state_dict.items():
# name = k[7:] # remove module.
name = k[12:] # remove module.body.
new_state_dict[name] = v
# load params
backbone.load_state_dict(new_state_dict)
but front this error
RuntimeError: Error(s) in loading state_dict for MobileNetV1:
Missing key(s) in state_dict: "stage1.0.0.weight", "stage1.0.1.weight", "stage1.0.1.bias", "stage1.0.1.running_mean", "stage1.0.1.running_var", "stage1.1.0.weight", "stage1.1.1.weight", "stage1.1.1.bias", "stage1.1.1.running_mean", "stage1.1.1.running_var", "stage1.1.3.weight", "stage1.1.4.weight", "stage1.1.4.bias", "stage1.1.4.running_mean", "stage1.1.4.running_var", "stage1.2.0.weight", "stage1.2.1.weight", "stage1.2.1.bias", "stage1.2.1.running_mean", "stage1.2.1.running_var", "stage1.2.3.weight", "stage1.2.4.weight", "stage1.2.4.bias", "stage1.2.4.running_mean", "stage1.2.4.running_var", "stage1.3.0.weight", "stage1.3.1.weight", "stage1.3.1.bias", "stage1.3.1.running_mean", "stage1.3.1.running_var", "stage1.3.3.weight", "stage1.3.4.weight", "stage1.3.4.bias", "stage1.3.4.running_mean", "stage1.3.4.running_var", "stage1.4.0.weight", "stage1.4.1.weight", "stage1.4.1.bias", "stage1.4.1.running_mean", "stage1.4.1.running_var", "stage1.4.3.weight", "stage1.4.4.weight", "stage1.4.4.bias", "stage1.4.4.running_mean", "stage1.4.4.running_var", "stage1.5.0.weight", "stage1.5.1.weight", "stage1.5.1.bias", "stage1.5.1.running_mean", "stage1.5.1.running_var", "stage1.5.3.weight", "stage1.5.4.weight", "stage1.5.4.bias", "stage1.5.4.running_mean", "stage1.5.4.running_var", "stage2.0.0.weight", "stage2.0.1.weight", "stage2.0.1.bias", "stage2.0.1.running_mean", "stage2.0.1.running_var", "stage2.0.3.weight", "stage2.0.4.weight", "stage2.0.4.bias", "stage2.0.4.running_mean", "stage2.0.4.running_var", "stage2.1.0.weight", "stage2.1.1.weight", "stage2.1.1.bias", "stage2.1.1.running_mean", "stage2.1.1.running_var", "stage2.1.3.weight", "stage2.1.4.weight", "stage2.1.4.bias", "stage2.1.4.running_mean", "stage2.1.4.running_var", "stage2.2.0.weight", "stage2.2.1.weight", "stage2.2.1.bias", "stage2.2.1.running_mean", "stage2.2.1.running_var", "stage2.2.3.weight", "stage2.2.4.weight", "stage2.2.4.bias", "stage2.2.4.running_mean", "stage2.2.4.running_var", "stage2.3.0.weight", "stage2.3.1.weight", "stage2.3.1.bias", "stage2.3.1.running_mean", "stage2.3.1.running_var", "stage2.3.3.weight", "stage2.3.4.weight", "stage2.3.4.bias", "stage2.3.4.running_mean", "stage2.3.4.running_var", "stage2.4.0.weight", "stage2.4.1.weight", "stage2.4.1.bias", "stage2.4.1.running_mean", "stage2.4.1.running_var", "stage2.4.3.weight", "stage2.4.4.weight", "stage2.4.4.bias", "stage2.4.4.running_mean", "stage2.4.4.running_var", "stage2.5.0.weight", "stage2.5.1.weight", "stage2.5.1.bias", "stage2.5.1.running_mean", "stage2.5.1.running_var", "stage2.5.3.weight", "stage2.5.4.weight", "stage2.5.4.bias", "stage2.5.4.running_mean", "stage2.5.4.running_var", "stage3.0.0.weight", "stage3.0.1.weight", "stage3.0.1.bias", "stage3.0.1.running_mean", "stage3.0.1.running_var", "stage3.0.3.weight", "stage3.0.4.weight", "stage3.0.4.bias", "stage3.0.4.running_mean", "stage3.0.4.running_var", "stage3.1.0.weight", "stage3.1.1.weight", "stage3.1.1.bias", "stage3.1.1.running_mean", "stage3.1.1.running_var", "stage3.1.3.weight", "stage3.1.4.weight", "stage3.1.4.bias", "stage3.1.4.running_mean", "stage3.1.4.running_var", "fc.weight", "fc.bias".
Unexpected key(s) in state_dict: "body.stage1.0.0.weight", "body.stage1.0.1.weight", "body.stage1.0.1.bias", "body.stage1.0.1.running_mean", "body.stage1.0.1.running_var", "body.stage1.0.1.num_batches_tracked", "body.stage1.1.0.weight", "body.stage1.1.1.weight", "body.stage1.1.1.bias", "body.stage1.1.1.running_mean", "body.stage1.1.1.running_var", "body.stage1.1.1.num_batches_tracked", "body.stage1.1.3.weight", "body.stage1.1.4.weight", "body.stage1.1.4.bias", "body.stage1.1.4.running_mean", "body.stage1.1.4.running_var", "body.stage1.1.4.num_batches_tracked", "body.stage1.2.0.weight", "body.stage1.2.1.weight", "body.stage1.2.1.bias", "body.stage1.2.1.running_mean", "body.stage1.2.1.running_var", "body.stage1.2.1.num_batches_tracked", "body.stage1.2.3.weight", "body.stage1.2.4.weight", "body.stage1.2.4.bias", "body.stage1.2.4.running_mean", "body.stage1.2.4.running_var", "body.stage1.2.4.num_batches_tracked", "body.stage1.3.0.weight", "body.stage1.3.1.weight", "body.stage1.3.1.bias", "body.stage1.3.1.running_mean", "body.stage1.3.1.running_var", "body.stage1.3.1.num_batches_tracked", "body.stage1.3.3.weight", "body.stage1.3.4.weight", "body.stage1.3.4.bias", "body.stage1.3.4.running_mean", "body.stage1.3.4.running_var", "body.stage1.3.4.num_batches_tracked", "body.stage1.4.0.weight", "body.stage1.4.1.weight", "body.stage1.4.1.bias", "body.stage1.4.1.running_mean", "body.stage1.4.1.running_var", "body.stage1.4.1.num_batches_tracked", "body.stage1.4.3.weight", "body.stage1.4.4.weight", "body.stage1.4.4.bias", "body.stage1.4.4.running_mean", "body.stage1.4.4.running_var", "body.stage1.4.4.num_batches_tracked", "body.stage1.5.0.weight", "body.stage1.5.1.weight", "body.stage1.5.1.bias", "body.stage1.5.1.running_mean", "body.stage1.5.1.running_var", "body.stage1.5.1.num_batches_tracked", "body.stage1.5.3.weight", "body.stage1.5.4.weight", "body.stage1.5.4.bias", "body.stage1.5.4.running_mean", "body.stage1.5.4.running_var", "body.stage1.5.4.num_batches_tracked", "body.stage2.0.0.weight", "body.stage2.0.1.weight", "body.stage2.0.1.bias", "body.stage2.0.1.running_mean", "body.stage2.0.1.running_var", "body.stage2.0.1.num_batches_tracked", "body.stage2.0.3.weight", "body.stage2.0.4.weight", "body.stage2.0.4.bias", "body.stage2.0.4.running_mean", "body.stage2.0.4.running_var", "body.stage2.0.4.num_batches_tracked", "body.stage2.1.0.weight", "body.stage2.1.1.weight", "body.stage2.1.1.bias", "body.stage2.1.1.running_mean", "body.stage2.1.1.running_var", "body.stage2.1.1.num_batches_tracked", "body.stage2.1.3.weight", "body.stage2.1.4.weight", "body.stage2.1.4.bias", "body.stage2.1.4.running_mean", "body.stage2.1.4.running_var", "body.stage2.1.4.num_batches_tracked", "body.stage2.2.0.weight", "body.stage2.2.1.weight", "body.stage2.2.1.bias", "body.stage2.2.1.running_mean", "body.stage2.2.1.running_var", "body.stage2.2.1.num_batches_tracked", "body.stage2.2.3.weight", "body.stage2.2.4.weight", "body.stage2.2.4.bias", "body.stage2.2.4.running_mean", "body.stage2.2.4.running_var", "body.stage2.2.4.num_batches_tracked", "body.stage2.3.0.weight", "body.stage2.3.1.weight", "body.stage2.3.1.bias", "body.stage2.3.1.running_mean", "body.stage2.3.1.running_var", "body.stage2.3.1.num_batches_tracked", "body.stage2.3.3.weight", "body.stage2.3.4.weight", "body.stage2.3.4.bias", "body.stage2.3.4.running_mean", "body.stage2.3.4.running_var", "body.stage2.3.4.num_batches_tracked", "body.stage2.4.0.weight", "body.stage2.4.1.weight", "body.stage2.4.1.bias", "body.stage2.4.1.running_mean", "body.stage2.4.1.running_var", "body.stage2.4.1.num_batches_tracked", "body.stage2.4.3.weight", "body.stage2.4.4.weight", "body.stage2.4.4.bias", "body.stage2.4.4.running_mean", "body.stage2.4.4.running_var", "body.stage2.4.4.num_batches_tracked", "body.stage2.5.0.weight", "body.stage2.5.1.weight", "body.stage2.5.1.bias", "body.stage2.5.1.running_mean", "body.stage2.5.1.running_var", "body.stage2.5.1.num_batches_tracked", "body.stage2.5.3.weight", "body.stage2.5.4.weight", "body.stage2.5.4.bias", "body.stage2.5.4.running_mean", "body.stage2.5.4.running_var", "body.stage2.5.4.num_batches_tracked", "body.stage3.0.0.weight", "body.stage3.0.1.weight", "body.stage3.0.1.bias", "body.stage3.0.1.running_mean", "body.stage3.0.1.running_var", "body.stage3.0.1.num_batches_tracked", "body.stage3.0.3.weight", "body.stage3.0.4.weight", "body.stage3.0.4.bias", "body.stage3.0.4.running_mean", "body.stage3.0.4.running_var", "body.stage3.0.4.num_batches_tracked", "body.stage3.1.0.weight", "body.stage3.1.1.weight", "body.stage3.1.1.bias", "body.stage3.1.1.running_mean", "body.stage3.1.1.running_var", "body.stage3.1.1.num_batches_tracked", "body.stage3.1.3.weight", "body.stage3.1.4.weight", "body.stage3.1.4.bias", "body.stage3.1.4.running_mean", "body.stage3.1.4.running_var", "body.stage3.1.4.num_batches_tracked", "fpn.output1.0.weight", "fpn.output1.1.weight", "fpn.output1.1.bias", "fpn.output1.1.running_mean", "fpn.output1.1.running_var", "fpn.output1.1.num_batches_tracked", "fpn.output2.0.weight", "fpn.output2.1.weight", "fpn.output2.1.bias", "fpn.output2.1.running_mean", "fpn.output2.1.running_var", "fpn.output2.1.num_batches_tracked", "fpn.output3.0.weight", "fpn.output3.1.weight", "fpn.output3.1.bias", "fpn.output3.1.running_mean", "fpn.output3.1.running_var", "fpn.output3.1.num_batches_tracked", "fpn.merge1.0.weight", "fpn.merge1.1.weight", "fpn.merge1.1.bias", "fpn.merge1.1.running_mean", "fpn.merge1.1.running_var", "fpn.merge1.1.num_batches_tracked", "fpn.merge2.0.weight", "fpn.merge2.1.weight", "fpn.merge2.1.bias", "fpn.merge2.1.running_mean", "fpn.merge2.1.running_var", "fpn.merge2.1.num_batches_tracked", "ssh1.conv3X3.0.weight", "ssh1.conv3X3.1.weight", "ssh1.conv3X3.1.bias", "ssh1.conv3X3.1.running_mean", "ssh1.conv3X3.1.running_var", "ssh1.conv3X3.1.num_batches_tracked", "ssh1.conv5X5_1.0.weight", "ssh1.conv5X5_1.1.weight", "ssh1.conv5X5_1.1.bias", "ssh1.conv5X5_1.1.running_mean", "ssh1.conv5X5_1.1.running_var", "ssh1.conv5X5_1.1.num_batches_tracked", "ssh1.conv5X5_2.0.weight", "ssh1.conv5X5_2.1.weight", "ssh1.conv5X5_2.1.bias", "ssh1.conv5X5_2.1.running_mean", "ssh1.conv5X5_2.1.running_var", "ssh1.conv5X5_2.1.num_batches_tracked", "ssh1.conv7X7_2.0.weight", "ssh1.conv7X7_2.1.weight", "ssh1.conv7X7_2.1.bias", "ssh1.conv7X7_2.1.running_mean", "ssh1.conv7X7_2.1.running_var", "ssh1.conv7X7_2.1.num_batches_tracked", "ssh1.conv7x7_3.0.weight", "ssh1.conv7x7_3.1.weight", "ssh1.conv7x7_3.1.bias", "ssh1.conv7x7_3.1.running_mean", "ssh1.conv7x7_3.1.running_var", "ssh1.conv7x7_3.1.num_batches_tracked", "ssh2.conv3X3.0.weight", "ssh2.conv3X3.1.weight", "ssh2.conv3X3.1.bias", "ssh2.conv3X3.1.running_mean", "ssh2.conv3X3.1.running_var", "ssh2.conv3X3.1.num_batches_tracked", "ssh2.conv5X5_1.0.weight", "ssh2.conv5X5_1.1.weight", "ssh2.conv5X5_1.1.bias", "ssh2.conv5X5_1.1.running_mean", "ssh2.conv5X5_1.1.running_var", "ssh2.conv5X5_1.1.num_batches_tracked", "ssh2.conv5X5_2.0.weight", "ssh2.conv5X5_2.1.weight", "ssh2.conv5X5_2.1.bias", "ssh2.conv5X5_2.1.running_mean", "ssh2.conv5X5_2.1.running_var", "ssh2.conv5X5_2.1.num_batches_tracked", "ssh2.conv7X7_2.0.weight", "ssh2.conv7X7_2.1.weight", "ssh2.conv7X7_2.1.bias", "ssh2.conv7X7_2.1.running_mean", "ssh2.conv7X7_2.1.running_var", "ssh2.conv7X7_2.1.num_batches_tracked", "ssh2.conv7x7_3.0.weight", "ssh2.conv7x7_3.1.weight", "ssh2.conv7x7_3.1.bias", "ssh2.conv7x7_3.1.running_mean", "ssh2.conv7x7_3.1.running_var", "ssh2.conv7x7_3.1.num_batches_tracked", "ssh3.conv3X3.0.weight", "ssh3.conv3X3.1.weight", "ssh3.conv3X3.1.bias", "ssh3.conv3X3.1.running_mean", "ssh3.conv3X3.1.running_var", "ssh3.conv3X3.1.num_batches_tracked", "ssh3.conv5X5_1.0.weight", "ssh3.conv5X5_1.1.weight", "ssh3.conv5X5_1.1.bias", "ssh3.conv5X5_1.1.running_mean", "ssh3.conv5X5_1.1.running_var", "ssh3.conv5X5_1.1.num_batches_tracked", "ssh3.conv5X5_2.0.weight", "ssh3.conv5X5_2.1.weight", "ssh3.conv5X5_2.1.bias", "ssh3.conv5X5_2.1.running_mean", "ssh3.conv5X5_2.1.running_var", "ssh3.conv5X5_2.1.num_batches_tracked", "ssh3.conv7X7_2.0.weight", "ssh3.conv7X7_2.1.weight", "ssh3.conv7X7_2.1.bias", "ssh3.conv7X7_2.1.running_mean", "ssh3.conv7X7_2.1.running_var", "ssh3.conv7X7_2.1.num_batches_tracked", "ssh3.conv7x7_3.0.weight", "ssh3.conv7x7_3.1.weight", "ssh3.conv7x7_3.1.bias", "ssh3.conv7x7_3.1.running_mean", "ssh3.conv7x7_3.1.running_var", "ssh3.conv7x7_3.1.num_batches_tracked", "ClassHead.0.conv1x1.weight", "ClassHead.0.conv1x1.bias", "ClassHead.1.conv1x1.weight", "ClassHead.1.conv1x1.bias", "ClassHead.2.conv1x1.weight", "ClassHead.2.conv1x1.bias", "BboxHead.0.conv1x1.weight", "BboxHead.0.conv1x1.bias", "BboxHead.1.conv1x1.weight", "BboxHead.1.conv1x1.bias", "BboxHead.2.conv1x1.weight", "BboxHead.2.conv1x1.bias", "LandmarkHead.0.conv1x1.weight", "LandmarkHead.0.conv1x1.bias", "LandmarkHead.1.conv1x1.weight", "LandmarkHead.1.conv1x1.bias", "LandmarkHead.2.conv1x1.weight", "LandmarkHead.2.conv1x1.bias".
How can I do?