import torch


def Entropy(softprob):
    """ Compute the Shannon Entropy of a vector of soft probabilities.
    softprob: pytorch tensor. Vector of soft probabilities with shape [batch,num_classes]
    outputs -> pytorch tensor containing the entropy of each sample in the batch
    """
    epsilon = 1e-8
    return - torch.sum(softprob * torch.log(softprob + epsilon), 1)