import torch


def calc_accuracy(preds, targets):
    """
    Compare preds and targets to calculate accuracy
    Args
        - preds: batched predictions
        - targets: batched targets
    Return
        a single accuracy number
    """
    with torch.no_grad():
        equals = torch.mean(preds.eq(targets).type(torch.FloatTensor))
        return equals.item()