I am curious about the layer naming (key values of state_dict) of the vgg16 pretrained model from torchvision.models module, e.g.: ‘features.0.weight’, ‘features.0.bias’, ‘features.2.weight’, ‘features.2.bias’, etc. The number increases by 2 with each new convolutional or fc layer, and increases by 3 each time encountering a max pooling layer.
Do you have an idea of the underlying logic?
Thank you very much!
The numbered indices in these modules names are created by the
Layers without any parameters will still get the index, but won’t be shown in the
Here is a small example:
model = nn.Sequential(
> odict_keys(['0.weight', '0.bias', '2.weight', '2.bias', '5.weight', '5.bias'])
As you can see, only the layer indices 0, 2, and 5 are shown, as these layers contain parameters.