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

Question on the implementation of ArcFace loss #2

Open
TMaysGGS opened this issue Dec 23, 2019 · 0 comments
Open

Question on the implementation of ArcFace loss #2

TMaysGGS opened this issue Dec 23, 2019 · 0 comments

Comments

@TMaysGGS
Copy link

Hi @ewrfcas ,

Thanks for sharing your code about the Keras implementation of ArcFace loss. I recently use this loss to train my model but found something that really confuses me.

In the code below, y_mask =+ K.epsilon() will make y_mask always be equal to K.epsilon(), which is default to 1e-7. This makes the whole loss be equivalent to Softmax since the term cos_tm_temp * y_mask has been almost eliminated.

On the other side, I tried deleting this line to make y_mask become the one-hot form true label, but then the loss become a constant so that the weights & biases do not updates anymore.

So I wonder if you have some advice on this. BTW, do you know how to print out the intermediate values in a custom loss layer? I debugged the loss function line by line and it seems right, while the outcomes when training is not. :(

y_mask =+ K.epsilon()
inv_mask = 1. - y_mask
s_cos_theta = self.s * cos_theta
output = K.softmax((s_cos_theta * inv_mask) + (cos_tm_temp * y_mask))

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