Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Something went wrong when changing default config #37

Open
tungedng2710 opened this issue May 31, 2022 · 0 comments
Open

Something went wrong when changing default config #37

tungedng2710 opened this issue May 31, 2022 · 0 comments

Comments

@tungedng2710
Copy link

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant