-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Description
I have implemented your code and trained with "Aircraft" dataset. It worked normally until I tried to change your CE loss function into ArcFace loss and your SGD optimizer into Adam. The code still worked but I achieve log: "there is one img no intersection" and the accuracy is very low (approximately 1%). What happened?
There is my ArcFace loss
class ArcFaceLoss(nn.Module):
def __init__(self, s=30.0, m=0.50, is_cuda=True, base_loss = 'CrossEntropyLoss'):
super(ArcFaceLoss, self).__init__()
self.s = s
self.m = m
self.criterion = nn.CrossEntropyLoss()
self.criterion = self.criterion.cuda()
def forward(self, input, label):
theta = torch.acos(torch.clamp(input, -1.0 + 1e-7, 1.0 - 1e-7))
target_logits = torch.cos(theta + self.m)
one_hot = torch.zeros_like(input)
one_hot.scatter_(1, label.view(-1, 1).long(), 1)
output = input * (1 - one_hot) + target_logits * one_hot
output = output * self.s
return self.criterion(output, label)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels