Hi,
I have defined a pretrained resnet50 for data parallelism using multiple classes and use nn.CrossEntropyLoss() .
model = models.resnet50(pretrained=True)
model = torch.nn.DataParallel(model)
for p in model.parameters():
      p.requires_grad = False
num_ftrs = model.module.fc.in_features
model.module.fc = nn.Linear(num_ftrs, num_classes)
model = model.to(device)

However, I’m unsure of how to use BCE Loss. I have read that it is better to use nn.BCELoss() for two classes, however, I don’t know if I need to define a sigmoid layer. And if so, where to put this layer…
Cheers,
T