clcarwin / sphereface_pytorch

A PyTorch Implementation of SphereFace.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it the correct way to calculate cross_entropy

xf1994 opened this issue · comments

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.