Pytorch: How to find accuracy for Multi Label Classification?
I am using vgg16, where number of classes is 3, and I can have multiple labels predicted for a data point.

vgg16 = models.vgg16(pretrained=True)
vgg16.classifier[6]= nn.Linear(4096, 3)

using loss function : nn.BCEWithLogitsLoss()

I am able to find find accuracy in case of a single label problem, as

 `images, labels = data
 images, labels = images.to(device), labels.to(device)
 labels = Encode(labels)
 outputs = vgg16(images)
 _, predicted = torch.max(outputs.data, 1)
 total += labels.size(0)
 correct += (predicted == labels).sum().item()
 acc = (100 * correct / total)`


How can I find accuracy for multi label classification?

From your question, vgg16 is returning raw logits. So here's what you can do:

labels = Encode(labels)  # torch.Size([N, C]) e.g. tensor([[1., 1., 1.]])
outputs = vgg16(images)  # torch.Size([N, C])
outputs = torch.sigmoid(outputs)  # torch.Size([N, C]) e.g. tensor([[0., 0.5, 0.]])
outputs[outputs &gt;= 0.5] = 1
accuracy = (outputs == labels).sum()/(N*C)*100

