import torch


def accuracy(probs, targets):
    """Computes accuracy given predicted probabilities and expected labels.

    Args:
        probs: torch.FloatTensor[batch_size, 1], probabilities of a positive class
        targets: torch.LongTensor[batch_size, 1], true classes

    Returns:
        0 <= float <= 1, proportion of correct predictions
    """
    predictions = (probs >= 0.5).flatten()
    targets = targets.flatten()
    acc = torch.sum(predictions == targets).float() / targets.shape[0]
    acc = float(acc)

    return acc