If I understand your use case correctly you are dealing with two “labels”, each consisting of 10 classes.
Each sample belongs to one particular class of each label.
I think in that particular use case you could use two linear layers, one for each label, and return these two outputs:
class MyModel(nn.Module):
def __init__(self, num_classes1, num_classes2):
super(MyModel, self).__init__()
self.model_resnet = models.resnet18(pretrained=True)
num_ftrs = self.model_resnet.fc.in_features
self.model_resnet.fc = nn.Identity()
self.fc1 = nn.Linear(num_ftrs, num_classes1)
self.fc2 = nn.Linear(num_ftrs, num_classes2)
def forward(self, x):
x = self.model_resnet(x)
out1 = self.fc1(x)
out2 = self.fc2(x)
return out1, out2