Is there a mistake in the implementation of vgg network in torchvision models?

In the source of vgg implementation from torchvision I see the the following call to the main VGG class

def _vgg(arch, cfg, batch_norm, pretrained, progress, **kwargs):
    if pretrained:
        kwargs['init_weights'] = False
 calling main VGG class --> model = VGG(make_layers(cfgs[cfg], batch_norm=batch_norm), **kwargs)
    if pretrained:
        state_dict = load_state_dict_from_url(model_urls[arch],
                                              progress=progress)
        model.load_state_dict(state_dict)
    return model

the signature of VGG class doesn’t take any **kwargs as input

class VGG(nn.Module):

    def __init__(self, features, num_classes=1000, init_weights=True): <--- no **kwargs inputs
        super(VGG, self).__init__()
        self.features = features
        self.avgpool = nn.AdaptiveAvgPool2d((7, 7))
        self.classifier = nn.Sequential(
            nn.Linear(512 * 7 * 7, 4096),
            nn.ReLU(True),
            nn.Dropout(),
            nn.Linear(4096, 4096),
            nn.ReLU(True),
            nn.Dropout(),
            nn.Linear(4096, num_classes),
        )

as consequence calling _vgg('vgg13_bn', 'B', True, pretrained, progress, **kwargs) where in the **kwargs we add dropout_rate=0.5 will result in an error

    model = VGG(make_layers(cfgs[cfg], batch_norm=batch_norm), **kwargs)
TypeError: __init__() got an unexpected keyword argument 'dropout_rate'

kwargs is unpacked to e.g. init_weights = False inside VGG's __init__ method.

Even if that’s the case, does it seem the right thing to do?
I guess the question is why silently unpack **kwargs into init_weights? Why not make explicit and easier for everyone read it.

Finally, I don’t see in the current implementation how could anyone use **kwargs to setup dropout rate in the dropout layers, so the whole point of having **kwargs in the first place seems to be vacuous.

Since kwargs is passed to the VGG class, you can use it to specify e.g. num_classes:

model = models.vgg11(num_classes=11)

The kwargs argument is used in the current approach to use the specific models definitions, e.g. vgg11, vgg16, as an abstraction layer and pass additional arguments to the construction of the model.

If you want to be able to pass more arguments and think that changing the dropout probability is a missing feature, I would recommend to create a feature request on GitHub with your proposal.