clcarwin / sphereface_pytorch

A PyTorch Implementation of SphereFace.
MIT License
714 stars 172 forks source link

Is it the correct way to calculate cross_entropy #22

Closed xf1994 closed 6 years ago

xf1994 commented 6 years ago

In your implementation of Angleloss, the cross_entropy is calculated as:

    logpt = F.log_softmax(output)
    logpt = logpt.gather(1,target)
    logpt = logpt.view(-1)
    pt = Variable(logpt.data.exp())

    loss = -1 * (1-pt)**self.gamma * logpt
    loss = loss.mean()

It seems you only calculate the entropy of the target samples. Others are not calculated.