-
Notifications
You must be signed in to change notification settings - Fork 19.4k
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
Dice loss - incorrect #19637
Labels
Comments
Sure, we could add |
Yes, I am not sure if I created PR correctly, but here it is: #19673 |
td-jakubl
added a commit
to td-jakubl/keras
that referenced
this issue
May 6, 2024
fchollet
pushed a commit
that referenced
this issue
May 16, 2024
* Add axis parameter to dice loss #19637 * Add unit test * Reformat code
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tensorflow version 2.16.1 (https://www.tensorflow.org/api_docs/python/tf/keras/losses/Dice)
The calculated dice loss is the average of all values in the tensor, which is not always true e.g. for tensors with shape
(batch_size, height, width, 1)
:The expected result should be
tf.Tensor([0.5 0.7575755 ], shape=(2,), dtype=float32)
instead oftf.Tensor(0.6164384, shape=(), dtype=float32)
Proposed solution:
Adding an axis parameter for which dimensions the loss is to be calculated, analogous to the:
tf.keras.losses.BinaryCrossentropy
(https://www.tensorflow.org/api_docs/python/tf/keras/losses/BinaryCrossentropy)The text was updated successfully, but these errors were encountered: