Question 1
Consider the following code snippets for loading and modifying VGGNet-16 and VGGNet-19 architectures for a classification task with 10 classes:
import torchimport torch.nn as nnfrom torchvision.models import vgg16, vgg19
# Block A: VGGNet-16 with modified classification headclass VGG16Modified(nn.Module): def __init__(self, num_classes=10): super(VGG16Modified, self).__init__() self.vgg16 = vgg16(pretrained=True) self.vgg16.classifier[6] = nn.Linear(4096, num_classes)
def forward(self, x): return self.vgg16(x)
model_a = VGG16Modified()
# Block B: VGGNet-19 with modified classification headclass VGG19Modified(nn.Module): def __init__(self, num_classes=10): super(VGG19Modified, self).__init__() self.vgg19 = vgg19(pretrained=True) self.vgg19.classifier[6] = nn.Linear(4096, num_classes)
def forward(self, x): return self.vgg19(x)
model_b = VGG19Modified()
# Block C: Loading VGGNet-16 and freezing feature extraction layersvgg16_model = vgg16(pretrained=True)for param in vgg16_model.features.parameters(): param.requires_grad = Falsevgg16_model.classifier[6] = nn.Linear(4096, 10)
# Block D: VGGNet-19 with feature extraction layers unfrozenvgg19_model = vgg19(pretrained=True)vgg19_model.classifier[6] = nn.Linear(4096, 10)Which of the following statements are true about the provided blocks?
(a) Block A uses VGGNet-16 and modifies the classification head to support 10 classes.
(b) Block B and Block C both use VGGNet-19 but differ in how feature extraction layers are handled.
(c) Block C freezes the feature extraction layers in VGGNet-16 for transfer learning.
(d) Block D unfreezes feature extraction layers in VGGNet-19, making it trainable end-to-end.
Select the correct options:
(a) and (c)
(b) and (d)
(a), (c), and (d)
All of these