torchcv: Key mismatch while loading the model?
I am having issue loading the trained checkpoint to FPNSSD512 model. How can I fix that?
RuntimeError: Error(s) in loading state_dict for FPNSSD512:
Missing key(s) in state_dict: "fpn.conv1.weight", "fpn.bn1.running_var", "fpn.bn1.bias", "fpn.bn1.running_mean", "fpn.bn1.weight", "fpn.layer1.0.conv1.weight", "fpn.layer1.0.bn1.running_var", "fpn.layer1.0.bn1.bias", "fpn.layer1.0.bn1.running_mean", "fpn.layer1.0.bn1.weight", "fpn.layer1.0.conv2.weight", "fpn.layer1.0.bn2.running_var", "fpn.layer1.0.bn2.bias",
Unexpected key(s) in state_dict: "module.fpn.conv1.weight", "module.fpn.bn1.weight", "module.fpn.bn1.bias", "module.fpn.bn1.running_mean", "module.fpn.bn1.running_var", "module.fpn.layer1.0.conv1.weight"
About this issue
- Original URL
- State: open
- Created 6 years ago
- Comments: 17
If you want to load the weights after
DataParallel
use:net.module.load_state_dict(pertained_weights)
If you want to load the weights beforeDataParallel
use:net.load_state_dict(pertained_weights)
@ahkarami I uploaded the sgd training and eval log. And with sgd, I can only got aound 76% mAP now. The pretrained model was in here.
@ahkarami Please check my code. https://github.com/silkylove/ObjectDetection/tree/master/example/fpnssd I also uploaded the training log with adam with 100 epochs which could get 73.95mAP until now. I am now training SGD with 200 epochs on that which I think would get higher mAP, I will release the training log later. Also, you can uncommen this line in eval.py https://github.com/silkylove/ObjectDetection/blob/master/example/fpnssd/eval.py#L25 to got his pertrained model’s performence (about 56mAP). And make sure not to use dataparallel.