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

[Feature Request] Circle loss implementation #182

Open
levyfan opened this issue Mar 30, 2020 · 0 comments
Open

[Feature Request] Circle loss implementation #182

levyfan opened this issue Mar 30, 2020 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@levyfan
Copy link

levyfan commented Mar 30, 2020

Circle loss is recently proposed (https://arxiv.org/abs/2002.10857) for image recognition tasks (face recognition, person re-identification, and image retrieval).

The implementation could be summarized as:

for i, j in ...:
    alpha_i = tf.stop_gradient(tf.nn.relu(1 + m - score_i))
    alpha_j = tf.stop_gradient(tf.nn.relu(score_j + m))
    loss = alpha_j * (score_j - m) - alpha_i * (score_i - 1 + m)
    loss = tf.exp(loss * gamma)
return tf.math.log1p(tf.math.reduce_sum(losses))

and score should be in [0, 1].

As for lambda weight, the loss might be modified as tf.math.log1p(tf.math.reduce_sum(losses * loss_weights)).

@bendersky bendersky added the enhancement New feature or request label May 20, 2020
@bendersky bendersky changed the title [feature request] Circle loss implementation [Feature Request] Circle loss implementation May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants