Question 5
You are building a classifier for a medical imaging dataset with 5 categories (e.g., types of skin lesions). You decide to use ResNet-18 pretrained on ImageNet and fine-tune only the final layer.
Below is a partially completed PyTorch code snippet:
import torchimport torch.nn as nnfrom torchvision.models import resnet18
class MedicalImageClassifier(nn.Module): def __init__(self): super(MedicalImageClassifier, self).__init__() self.base = resnet18(pretrained=True) # [Missing Line]
def forward(self, x): return self.base(x)
model = MedicalImageClassifier()Which of the following lines correctly fills in the missing line to adapt the ResNet-18 model for 5-class classification?