clcarwin / sphereface_pytorch

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

why not use torch.cos when calculating the value of phi ? #55

Closed niyunsheng closed 4 years ago

niyunsheng commented 4 years ago

I can calculating the value of phi using the code as follows:

cosine = F.linear(F.normalize(feature), F.normalize(self.weight))
theta = cosine.acos()
_phi = theta*m
k = _phi / torch.Tensor([np.pi])
k = k.floor()
_phi = _phi + torch.Tensor([np.pi])*k
_phi = _phi.cos() - k

is there any wrong? i think it's a better code by myself