kenshohara / 3D-ResNets-PyTorch

3D ResNets for Action Recognition (CVPR 2018)
MIT License
3.84k stars 930 forks source link

Train time on UFC101 fine tuning on fully connected layer and loading model query #242

Closed Purav-Zumkhawala closed 3 years ago

Purav-Zumkhawala commented 3 years ago

Hi,

I wanted to know how much time would it take to train the UFC101 on the resnet50 pre-trained model same as the last command given in the readme. I have an NVIDIA GeForce 2060 RTX GPU.

Also while loading the model I face RuntimeError: Error(s) in loading state_dict for ResNet: Here is the full error:

Traceback (most recent call last):
  File "main.py", line 428, in <module>
    main_worker(-1, opt)
  File "main.py", line 343, in main_worker
    opt.n_finetune_classes)
  File "C:\Users\purav\Downloads\Study\Project\3D-ResNets-PyTorch\model.py", line 102, in load_pretrained_model
    model.load_state_dict(pretrain['state_dict'])
  File "C:\Users\purav\anaconda3\envs\vision\lib\site-packages\torch\nn\modules\module.py", line 845, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for ResNet:

I solve this by adding a parameter strict = False. Would this hinder the training? If yes what is the solution for this? I believe this is because of the torch version. Is there a specific torch version required to run this perfectly?

I am asking this as the training starts till 3 epochs the accuracy is 0 only and I think that is abnormal as we are using a pre-trained model.

Please advise.

Purav-Zumkhawala commented 3 years ago

Regarding the training time it took 2 hours to complete 20 epochs on the UFC dataset on my pc with the above-mentioned specs.

We have to keep the strict parameter while loading the pre-trained model as True.

Now for the state_dict error, there were some keys missing and what I figured out is that the pre_trained model had state dict containing keys with 'module.' as prefix so I removed that and now the training happens successfully.