Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finetune pretrained model with custom number of classes #408

Closed
ayanasser opened this issue Dec 1, 2020 · 6 comments
Closed

Finetune pretrained model with custom number of classes #408

ayanasser opened this issue Dec 1, 2020 · 6 comments

Comments

@ayanasser
Copy link

Hi,
Do you have the ability for finetuning slowfast model but with 2 classes only?
in another word (could I change the number of classes of the last layer of "pretrained slowfastNet model"

because I want to take the feature from that pretrained model then classify those features with a simple 2 dense layers,
but I need to end up with one model, not 2 models (one for feature extraction and the other for classifying)
Thanks in advanced

@dreamerlin
Copy link
Collaborator

Refer to: #19 (comment)
Or you can modify load_from to the pretrained model checkpoint path or url, then change the num_classes, it will ignore the unexpected keys.

@ayanasser
Copy link
Author

ayanasser commented Dec 2, 2020

I want to freeze all the layers except the classifier layers (the last 2 layers), Does that accessible ?

@dreamerlin
Copy link
Collaborator

Try to use with torch.no_grad(): to wrap x = self.extract_feat(imgs), it will freeze the backbone.

@dreamerlin
Copy link
Collaborator

And If you feel we have help you, give us a STAR! : )

@ayanasser
Copy link
Author

you helped me a lot, sure I will, thank u ^^

@ayanasser
Copy link
Author

ayanasser commented Dec 11, 2020

Hi again :D, u said before that i could freeze the backbone by wrapping the features extracted with torch.no_grad(),
you mean by the backbone "resnet50" or you mean all the layers above the final softmax layer?
because while finetuning the slowfast model i need to freeze all the layers above the final softmax one,

second thing is i found that the backbone recognizer for slowfast is 3D not 2D, Is there a big difference between the 2 recognizers whilem finetunining the model with my custom video dataset ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants