I want to use the VGG16 pretrained network to classify a dataset of 1000 images into two classes. I also want the weights in the classifier part of the network to be initialized by Xavier initialization. How can I access the weights of the classifier part?
I have tried the following lines of code, but “model.classifier.parameters()” doesn’t seem to be the correct call to the weights of the classifier part.
    model = models.vgg16(pretrained=True)
    num_features = model.classifier[6].in_features
    features = list(model.classifier.children())[:-1] 
    features.extend([nn.Linear(num_features, 2)])  
    model.classifier = nn.Sequential(*features)  
    nn.init.xavier_normal(model.classifier.parameters()) 

Thanks!