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?
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] .