Error with Exercise 3 - single_class_dice_coefficient

I get two cases passed and two failed. My epsilon is 1 (not hardcoded). Not sure if I am using the axis parameter correctly.

Please help.

Also Keras.sum as mentioned in the lab does not exist. The link to the documentation
https://www.tensorflow.org/api_docs/python/tf/keras/backend/sum
is broken. You may want to note and correct this.


Test Case 1:

Pred:

[[1. 0.]
[0. 1.]]

Label:

[[1. 1.]
[0. 0.]]

Dice coefficient: 0.4


Test Case 2:

Pred:

[[1. 0.]
[0. 1.]]

Label:

[[1. 1.]
[0. 1.]]

Dice coefficient: 0.5

Error: Wrong output for Test Case 1. One possible reason for error: make sure epsilon = 1
Error: Wrong output for Test Case 2. One possible reason for error: make sure epsilon = 1
2 Tests passed
2 Tests failed

@Mubsi as above. Thanks.

@Mubsi. Please ignore. I solved it.

Hello @getjaidev
If you share how you solved this error, it will help fellow learners

Oh… I just forgot to put in a “2 *” in the numerator. My mistake.

In the multiple class section,

I get a wrong output for Test Case 3.


Pred:

class = 0
[[1. 0.]
[0. 1.]]

class = 1
[[1. 0.]
[0. 1.]]

Label:

class = 0
[[1. 1.]
[0. 0.]]

class = 1
[[1. 1.]
[0. 1.]]

Dice coefficient: 0.7

Error: Wrong output for Test Case 3. One possible reason for error: make sure epsilon = 1
6 Tests passed
1 Tests failed

@Mubsi

Please see above

Lab ID: tsranekg

Hi @getjaidev,

Your equations are wrong.

You can take a look in your notebook for more details.

Best,
Mubsi

This and other documentation hyperlinks have been updated.

Thank you @Mubsi . Much appreciated

1 Like