Skip to content

Output layer names for feature extractor #480

Answered by rwightman
code-demoe asked this question in Q&A
Discussion options

You must be logged in to vote

@code-demoe it's all in the feature_info object of the model after it's been created... any of the getters used below will by default return the values for the specified out_indices, but you can request the info for specific indices, including those that weren't selected if you want.

https://github.com/rwightman/pytorch-image-models/blob/f1f332fee50aa29c435b56cef16e137b6a6ca246/timm/models/features.py#L20-L82

model = timm.create_model('resnet50', features_only=True)

model.feature_info.channels()
[64, 256, 512, 1024, 2048]

model.feature_info.module_name()
['act1', 'layer1', 'layer2', 'layer3', 'layer4']

model.feature_info.get_dicts()
[{'num_chs': 64, 'reduction': 2, 'module': 'act1'}, {…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@code-demoe
Comment options

Answer selected by code-demoe
Comment options

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

@code-demoe
Comment options

@code-demoe
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
2 participants