I used CrossEntropyLoss before in a single-label classification problem and then I could calculate the accuracy like this:
_, predicted = torch.max(classified_labels.data, 1)
total = len(labels)
correct = (predicted == labels).sum()
accuracy = 100 * correct / total

Now I am trying to move on to a multi-label classification problem using MultiLabelMarginLoss or MultiLabelSoftMarginLoss (is this the right equivalent to choose?), I am unsure how to calculate the accuracy of classified_labels?
I came up with this for criterion = nn.MultiLabelSoftMarginLoss():
predicted = torch.clamp(torch.round(classified_labels.data), 0, 1).numpy().astype(int)
total = len(labels) * 17
correct = (predicted == labels.numpy().astype(int)).sum()
train_accuracy = 100 * correct / total

Is this correct?