My source is to classify three classes. I use this.
criterion = nn.CrossEntropyLoss().to(device)
optimizer_ft= optim.SGD(model_ft.parameters(), lr=0.01, momentum=0.9)
’
’
loss = criterion(outputs, target)
’
’
output: tensor ([[-21.6479, -24.8251, 46.5167],
[-7.8592, -16.6111, 24.4777]], device = ‘cuda : 0’)
target: tensor ([2, 2], device = ‘cuda : 0’)
I don’t know how to compare output and target.