Where is the documentation for `.features` parameter of a model?

Hi, I’m looking at the tutorial TORCHVISION OBJECT DETECTION FINETUNING TUTORIAL.

In the 2nd part of the tutorial, the author changes the backbone architecture of the pre-trained model by doing the following:

# load a pre-trained model for classification and return
# only the features
backbone = torchvision.models.mobilenet_v2(pretrained=True).features
...
...

What is .features actually doing? I can’t find its documentation.
Does it just return the final layer before a softmax?

1 Like

Yes, you are right. .features holds output of model without last classification layer or last fully connected layer. it is not a norm.

1 Like

Hey Yash, thanks for replying.

I’ve been looking this up, according to this post on the forum one can also slice the features layer-wise. Any idea about that?
Again docs would be really helpful

Yes, according to the architecture of MobileNet V2 you can slice off feature layer-wise because model.features is defined as self.features = nn.Sequential(*features) and nn.Sequential behaves like python list of all layers (so can be sliced). But for other models, you need to check its implementation. You check the model implementation here, by finding the right model and clicking on [SOURCE] .

1 Like

Thanks a lot, Yash, I guess I’ll have to check the source for every model I want to use.

I could not find the documentation of features parameter either. Does anyone know where it is ?