def accuracy(output, target):
    """
    Computes accuracy, from predicted and true labels.
    """

    batch_size = target.size(0)
    _, pred = output.topk(1, 1, True, True)
    correct = pred.eq(target.view(-1, 1).expand_as(pred))
    correct_total = correct.float().sum()
    return correct_total * (100.0 / batch_size)