lopuhin / kaggle-imet-2019

91 stars 24 forks source link

Try to use ResNet101 #4

Closed zhengli97 closed 5 years ago

zhengli97 commented 5 years ago

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 commented 5 years ago

Can’t check right now, maybe you need to pass the model parameter to main.py when you submit as well?

zhengli97 commented 5 years ago

@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.

lopuhin commented 5 years ago

@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

zhengli97 commented 5 years ago

Thank you!