Skip to content
Discussion options

You must be logged in to vote

@strugoeli there's actually some relevant discussion in this issue (feature request) #1141 .... but the creator of that issue was looking for both the embeddings and predictions.

If you just want the embeddings (the activations right before the classifier) that are shape (batch_size, num_features) the best way is

model = timm.create_model('resnet50', num_classes=0)`  # create model with no classifier (nn.Identity in place), but pooling still present

or

model = timm.create_model('resnet50')
model.reset_classifier(num_classes=0)  # remove classifier (replace with nn.Identity()) after creation

Then any model(input) will output the embedding

What you proposed will work for some of the simple…

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
2 replies
@strugoeli
Comment options

@rwightman
Comment options

Answer selected by strugoeli
Comment options

You must be logged in to vote
5 replies
@rwightman
Comment options

@rwightman
Comment options

@yonatanbitton
Comment options

@rwightman
Comment options

@rwightman
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants