Solved by ptrblck in post #5 
              
              
                The isinstance comparison is working: 
resnet18 = models.resnet18(pretrained=True)
resnet18.fc = nn.Linear(512, 10) 

for module in resnet18.modules():
    if isinstance(module, nn.Linear):
        print(module)

> Linear(in_features=512, out_features=10, bias=True)

as it returns the only nn.Linear …