Skip to content

how to get features from intermediate layers ? #1205

Answered by hankyul2
Husky-AI9 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @Husky95

If I understand the meaning of penultimate layer correctly, you can extract each layers output by passing features_only=True argument in create_model function. Here is code:

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 penultimate layer, please correct me: penultimate layer = final classification layer. Is it right?

I hope this answer can help you.

Thank you.

hankyul

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Husky-AI9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants