-
How would I got about extracting features of layer other than penultimate layers ? For example, what would the code look like if I want to get features from the layer before the penultimate layer in efficient_b0 model ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @Husky95 If I understand the meaning of import torch
from timm.models import create_model
model = create_model('efficientnet_b0', pretrained=True, features_only=True)
x = torch.rand([2, 3, 224, 224])
features = model(x) If I misunderstood the meaning of I hope this answer can help you. Thank you. hankyul |
Beta Was this translation helpful? Give feedback.
Hi @Husky95
If I understand the meaning of
penultimate layer
correctly, you can extract each layers output by passingfeatures_only=True
argument increate_model
function. Here is code:If I misunderstood the meaning of
penultimate layer
, please correct me:penultimate layer = final classification layer
. Is it right?I hope this answer can help you.
Thank you.
hankyul