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

Why add "neg_p_sub" into "per_entry_cross_ent" #10

Open
CoderChang opened this issue Sep 21, 2018 · 1 comment
Open

Why add "neg_p_sub" into "per_entry_cross_ent" #10

CoderChang opened this issue Sep 21, 2018 · 1 comment

Comments

@CoderChang
Copy link

For multi-label cases, I think there is no need to consider neg_p_sub while computing per_entry_cross_ent. I think we shouldn't take every class as a binary classification and sum up their binary-cross-entropy losses, but take all classes as a whole to compute the multiclass-cross-entropy loss.

The original code:

per_entry_cross_ent = - alpha * (pos_p_sub ** gamma) * tf.log(tf.clip_by_value(sigmoid_p, 1e-8, 1.0)) \
                          - (1 - alpha) * (neg_p_sub ** gamma) * tf.log(tf.clip_by_value(1.0 - sigmoid_p, 1e-8, 1.0))

I think it should be:

per_entry_cross_ent = - alpha * (pos_p_sub ** gamma) * tf.log(tf.clip_by_value(sigmoid_p, 1e-8, 1.0))
@lyuweiwang
Copy link

lyuweiwang commented Dec 5, 2018

I have tried this, the author's method is better. Although I thought you are right.

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