Try to use ResNet101
zhengli97 opened this issue · 4 comments
I am trying to use ResNet101 as backbone to train this nerual network.
I use this:
python main.py model_1 --model resnet101 --n-epoch 25
But when i was predicting:
python main.py predict_test model_1
This error happens:
RuntimeError: Error(s) in loading state_dict for ResNet:
Unexpected key(s) in state_dict: "net.layer3.6.conv1.weight", "net.layer3.6.bn1.weight", "net.layer3.6.bn1.bias", "net.layer3.6.bn1.running_mean", "net.layer3.6.bn1.running_var", "net.layer3.6.bn1.num_batches_tracked", "net.layer3.6.conv2.weight", "net.layer3.6.bn2.weight", "net.layer3.6.bn2.bias", "net.layer3.6.bn2.running_mean", "net.layer3.6.bn2.running_var", "net.layer3.6.bn2.num_batches_tracked", "net.layer3.6.conv3.weight"
......
I tried to change this:
net.load_state_dict(torch.load(weights_path)) in models.py
model.load_state_dict(state['model']) in utils.py
to this:
net.load_state_dict(torch.load(weights_path),strict=False)
model.load_state_dict(state['model'],strict=False)
But the score I got was very low. (0.1+)
I don't know how to solve this problem.
Can you please tell me how to change this code?
@lopuhin Hi, lopuhin
Thanks for you reply.
Sorry. I don't konw which model parameter should be passed to main.py.
Can you please check it when you have time? Thank you.
@mdlszli I meant you need to run python main.py predict_test model_1 --model resnet101
instead of python main.py predict_test model_1
Thank you!