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
How to remove the last layer? #227
Comments
Like this example from the README?
|
@lukemelas Thank you! |
@lukemelas Hi Lukemelas, I'm still a little confused. For b0, I expect a feature vector with torch.Size([1, 1280]), however I got torch.Size([1, 1280, 7, 7]). For ResNet I hook output of the last average pooling layer. How can I implement this in efficientnet? |
Does this work? features = model.extract_features(img)
pooled_features = torch.nn.functional.adaptive_avg_pool2d(features, 1) |
@lukemelas Got it! curious if setting model._fc = torch.nn.Identity() would work? |
Yup, that should work too! |
@lukemelas Now I'm clear. Thank you! |
Hi,
Great repo!
I'm doing an image retrieval task. I've already trained the model on my dataset and would like to use the backbone for feature extraction. In other words, I would like the output to be a feature vector. Should I simply remove the last _fc layer?
Thank you in advance!
Best,
Zach
The text was updated successfully, but these errors were encountered: