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 average loss value by batch_size when using batch_hard method? #55

Open
Hongtao-Niro opened this issue Jan 28, 2020 · 0 comments
Open

Comments

@Hongtao-Niro
Copy link

Hongtao-Niro commented Jan 28, 2020

Hi Olivier,

Thanks for your work, it helped me a lot! Just one question:

In the batch_hard_triplet_loss method, you calculate the average loss value using tf.reduce_mean, which is equivalent to tf.reduce_sum(tensor) / len(tensor). As a result the losses are averaged over batch_size. Shouldn't the output loss value be the average over number of non-zero losses? For example, let's say triplet_loss at line 218 is [1.4, 0, 0, 0 1.6], the output of the function will be 0.6 according to the code, but shouldn't it be 1.5?

I saw a similar discussion under your triplet loss post, but the code doesn't seem to reflect the thought.

@Hongtao-Niro Hongtao-Niro changed the title Why average loss value by batch size when using batch_hard method? Why average loss value by batch_size when using batch_hard method? Jan 28, 2020
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