kenshohara / video-classification-3d-cnn-pytorch

Video classification tools using 3D ResNet
MIT License
1.11k stars 260 forks source link

Missing and Unexpected key(s) in state_dict #64

Open ssy248 opened 3 years ago

ssy248 commented 3 years ago

When I run the command from the homepage python main.py --input ./input --video_root ./videos --output ./output.json --model wideresnet-50-kinetics.pth --mode score

after I saved the wideresnet-50-kinetics.pth model to the same folder as main.py, I still have the errors of

Missing key(s) in state_dict: "conv1.weight", "bn1.weight", "bn1.bias", "bn1.running_mean", "bn1.running_var", "layer1.0.conv1.weight", "layer1.0.bn1.weight", "layer1.0.bn1.bias", "layer1.0.bn1.running_mean", "layer1.0.bn1.running_var", "layer1.0.conv2.weight", .... and Unexpected key(s) in state_dict: "module.conv1.weight", "module.bn1.weight", "module.bn1.bias", "module.bn1.running_mean", "module.bn1.running_var", "module.layer1.0.conv1.weight", "module.layer1.0.bn1.weight", "module.layer1.0.bn1.bias", "module.layer1.0.bn1.running_mean", ...

Why do the keys from the correct model not match ?

dhruvgrover1251 commented 3 years ago

Hi, I think the model you are using is trained on multiple GPU (using nn.DataParallel), I was able to solve this either by removing "module." from the keys or by using the CPU version. Thank You!