# Autograder gives an error even though output matches expected output

**URL:** <https://community.deeplearning.ai/t/autograder-gives-an-error-even-though-output-matches-expected-output/303810>\
**Category:** Deep Learning Resources\
**Created:** [April 5, 2023, 8:15pm UTC](https://community.deeplearning.ai/t/autograder-gives-an-error-even-though-output-matches-expected-output/303810 "2023-04-05T20:15:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mahamood\_Hussain](https://avatars.discourse-cdn.com/v4/letter/m/df705f/32.png) [@Mahamood\_Hussain](https://community.deeplearning.ai/u/Mahamood_Hussain)\
**Post date:** [April 5, 2023, 8:15pm UTC](https://community.deeplearning.ai/t/autograder-gives-an-error-even-though-output-matches-expected-output/303810/1 "2023-04-05T20:15:34Z")

</div>

Hi - I’m on the last exercise of Wk3 of the Deep Learning assignment and I get a “Tests Failed” error even though the output of my cell matches exactly the ‘Expected Output’. i’ve been trying to figure out what is the issue but no luck. Any pointers will be appreciated. Thank you!

/notebooks/release/W4A1/Building\_your\_Deep\_Neural\_Network\_Step\_by\_Step.ipynb

 ![image](https://global.discourse-cdn.com/dlai/original/3X/a/f/af8771121aa2a97e9cf0ce15212770a5f1257805.png)

---

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [April 5, 2023, 8:36pm UTC](https://community.deeplearning.ai/t/autograder-gives-an-error-even-though-output-matches-expected-output/303810/2 "2023-04-05T20:36:26Z")

</div>

The problem is that there is more than one test there. You can see the output of the first test, but the others are contained in the file `public_tests.py`. The problem is the way you have copied the input `params` variable. That is a dictionary, but you did a simple copy. That does not actually copy the _entries_ in the dictionary, which in this case are numpy arrays which are python objects. So you are actually updating the global variables that are being passed in. That’s why the second set of tests failed: you’ve modifed the input values.

[Here’s a thread](https://community.deeplearning.ai/t/week-3-program-assignment-update-parameters/4016/2) which discusses this point in more detail. The “TL;DR” is that you need to use “deepcopy” not simple copy. That’s the cleanest solution or you can individually copy the entries in the `params` dictionary. Or you can rewrite the code not to use the “in place” operator += to do the individual updates. That is explained on that other thread.

---

<div class="post-metadata">

**Author:** ![Mahamood\_Hussain](https://avatars.discourse-cdn.com/v4/letter/m/df705f/32.png) [@Mahamood\_Hussain](https://community.deeplearning.ai/u/Mahamood_Hussain)\
**Post date:** [April 5, 2023, 9:17pm UTC](https://community.deeplearning.ai/t/autograder-gives-an-error-even-though-output-matches-expected-output/303810/3 "2023-04-05T21:17:29Z")

</div>

That definitely helped! Read the linked thread as well - Great info. Thank you @paulinpaloalto !

---

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [April 5, 2023, 9:37pm UTC](https://community.deeplearning.ai/t/autograder-gives-an-error-even-though-output-matches-expected-output/303810/4 "2023-04-05T21:37:35Z")

</div>

That’s good to hear! Did you also read [the later example on that same thread?](https://community.deeplearning.ai/t/week-3-program-assignment-update-parameters/4016/5)

---

<div class="post-metadata">

**Author:** ![Mahamood\_Hussain](https://avatars.discourse-cdn.com/v4/letter/m/df705f/32.png) [@Mahamood\_Hussain](https://community.deeplearning.ai/u/Mahamood_Hussain)\
**Post date:** [April 5, 2023, 10:59pm UTC](https://community.deeplearning.ai/t/autograder-gives-an-error-even-though-output-matches-expected-output/303810/5 "2023-04-05T22:59:21Z")

</div>

I did indeed. Good stuff!
