def accuracy(output, target, top_k=(1,)):
    """Calculate classification accuracy between output and target.

    :param output: output of classification network
    :type output: pytorch tensor
    :param target: ground truth from dataset
    :type target: pytorch tensor
    :param top_k: top k of metric, k is an interger
    :type top_k: tuple of interger
    :return: results of top k
    :rtype: list

    """
    max_k = max(top_k)
    batch_size = target.size(0)
    _, pred = output.topk(max_k, 1, True, True)
    pred = pred.t()
    correct = pred.eq(target.view(1, -1).expand_as(pred))
    res = []
    for k in top_k:
        correct_k = correct[:k].view(-1).float().sum(0)
        res.append(correct_k.mul_(100.0 / batch_size))
    return res