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'