# C1\_W3\_Assignment\_Exercise 5 - soft\_dice\_loss

**URL:** <https://community.deeplearning.ai/t/c1-w3-assignment-exercise-5-soft-dice-loss/805254>\
**Category:** AI for Medical Diagnosis\
**Tags:** week-module-1\
**Created:** [April 24, 2025, 11:32am UTC](https://community.deeplearning.ai/t/c1-w3-assignment-exercise-5-soft-dice-loss/805254 "2025-04-24T11:32:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dv.adler](https://avatars.discourse-cdn.com/v4/letter/d/7ea924/32.png) [@dv.adler](https://community.deeplearning.ai/u/dv.adler)\
**Post date:** [April 24, 2025, 11:32am UTC](https://community.deeplearning.ai/t/c1-w3-assignment-exercise-5-soft-dice-loss/805254/1 "2025-04-24T11:32:37Z")

</div>

Hello, i cant figure out why my code fails in some specific tests on soft\_dice\_loss function. this is the error i get:  
Error: Wrong output for Test Case 2. One possible reason for error: make sure epsilon = 1  
Error: Wrong output for Test Case 4. One possible reason for error: make sure epsilon = 1  
Error: Wrong output for Test Case 5. One possible reason for error: make sure epsilon = 1  
9 Tests passed  
3 Tests failed

* * *

AssertionError Traceback (most recent call last)  
 in ()  
6 ### do not edit anything below  
7 sess = K.get\_session()  
----\> 8 soft\_dice\_loss\_test(soft\_dice\_loss, epsilon, sess)

~/work/W3A1/public\_tests.py in soft\_dice\_loss\_test(target, epsilon, sess)  
412 ]  
413  
 → 414 multiple\_test\_dice(test\_cases, target, sess)  
415  
416 ##############################################

~/work/W3A1/test\_utils.py in multiple\_test\_dice(test\_cases, target, sess)  
183 print(‘\033[92m’, success," Tests passed")  
184 print(‘\033[91m’, len(test\_cases) - success, " Tests failed")  
 → 185 raise AssertionError(“Not all tests were passed for {}. Check your equations and avoid using global variables inside the function.”.format(target. **name** ))

AssertionError: Not all tests were passed for soft\_dice\_loss. Check your equations and avoid using global variables inside the function.

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [April 24, 2025, 6:27pm UTC](https://community.deeplearning.ai/t/c1-w3-assignment-exercise-5-soft-dice-loss/805254/2 "2025-04-24T18:27:26Z")

</div>

refer this post comment to understand what happens if you used global variables instead of local variables.

Based on your output for incorrect epsilon, you either have applied it multiple times or used the epsilon incorrectly.

> [@C1\_W3\_Assignment: UNQ\_C5](https://community.deeplearning.ai/t/c1-w3-assignment-unq-c5/465852/2):
>
> Hello Yosilia, Kindly remove the codes from your post. It is against community guidelines. You can always share a screenshot of your error or your output in comparison to the expected output. Have you noticed that DO NOT EDIT?? …there is no import statement for UNQ\_C5 cell. You have edited the grader cell, which will lead you to grader failure when you submit your assignment. If you have read these instructions before the cell We’ve explained the single class case for simplicity, b…
