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

Can't see asymmetric probability margin implementation in loss function. #58

Closed
sunlanchang opened this issue May 30, 2021 · 4 comments
Closed

Comments

@sunlanchang
Copy link

sunlanchang commented May 30, 2021

After reading ASL paper and source code, I am trying to find source code about asymmetric probability margin. But I can't see any code with respect to asymmetric probability margin in losses.py. Maybe bellow source code is about asymmetric probability margin?

# Asymmetric Clipping
if self.clip is not None and self.clip > 0:
    xs_neg = (xs_neg + self.clip).clamp(max=1)

But in ASL paper, asymmetric probability margin formula for negative sample is pm=max(p−m, 0), the source code does not make sense. I think the source code should be bellow:

# Asymmetric Clipping
if self.clip is not None and self.clip > 0:
    xs_neg = (xs_neg - self.clip).clamp(min=0)

I am not certain my understanding is right. Maybe I missed something, Please help me. Thanks!!!

@mrT23
Copy link
Contributor

mrT23 commented May 30, 2021

see:
#10

@sunlanchang
Copy link
Author

I can see define variable xs_pos and xs_neg to prevent calculating again and again (1-p) along the code. But I still can't understand why xs_neg = (xs_neg + self.clip).clamp(max=1) is equal to p_m = max(p-m, 0). Could you please describe the reason in details. Thanks a million.

@mrT23
Copy link
Contributor

mrT23 commented May 30, 2021

put actual numbers instead of a formula:

a sample got, for some label, probability 0.3, meaning p_xs_neg=1-0.3=0.7
if the ground-truth for the label is indeed negative, our target is: p_target_neg=1

with margin of 0.3 and above, we shouldnt have a loss. how do it with math:
xs_neg = (xs_neg + self.clip).clamp(max=1)
(don't forget - if the target is indeed negative, we want xs_neg to be 1, not 0, for not propagating a loss)

@sunlanchang
Copy link
Author

I can see, I'll close this issue. Thank you most sincerely.

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

2 participants