# Can anyone help? Where is the mistake? ML\_Course\_C3\_W2

**URL:** <https://community.deeplearning.ai/t/can-anyone-help-where-is-the-mistake-ml-course-c3-w2/178754>\
**Category:** Unsupervised Learning, Recommenders, Reinforcement\
**Tags:** week-module-2\
**Created:** [August 5, 2022, 3:00pm UTC](https://community.deeplearning.ai/t/can-anyone-help-where-is-the-mistake-ml-course-c3-w2/178754 "2022-08-05T15:00:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sultan007755](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@sultan007755](https://community.deeplearning.ai/u/sultan007755)\
**Post date:** [August 5, 2022, 3:00pm UTC](https://community.deeplearning.ai/t/can-anyone-help-where-is-the-mistake-ml-course-c3-w2/178754/1 "2022-08-05T15:00:18Z")

</div>

Can anyone help me?  
I did mistake in the first assignment of 3 course of 2 week. The mistake related to regularization term? Where should I add regularization term? Inside for loop or outside?

---

<div class="post-metadata">

**Author:** ![Lukasz\_S](https://avatars.discourse-cdn.com/v4/letter/l/ed8c4c/32.png) [@Lukasz\_S](https://community.deeplearning.ai/u/Lukasz_S)\
**Post date:** [August 5, 2022, 4:41pm UTC](https://community.deeplearning.ai/t/can-anyone-help-where-is-the-mistake-ml-course-c3-w2/178754/2 "2022-08-05T16:41:08Z")

</div>

Hi @sultan007755,

See the discussion here:

> [@c3\_w2\_UNQ\_C1 AssertionError: Wrong value. Expected 27, got 12.0](https://community.deeplearning.ai/t/c3-w2-unq-c1-assertionerror-wrong-value-expected-27-got-12-0/171612/12):
>
> Hi @Lucky_Agrawal, Look carefully at how the cost function J looks like: The regularization term is outside of the summation over i and j which means that it should be added to the J function after you exit from both for-loops (just before you divide J by 2). In your code, you added a regularization term inside the for-loop. Therefore you add it multiple times and you should add it only once.

And please delete your code. It is against Coursera rules to post an assignments code.

---

<div class="post-metadata">

**Author:** ![sultan007755](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@sultan007755](https://community.deeplearning.ai/u/sultan007755)\
**Post date:** [August 5, 2022, 6:06pm UTC](https://community.deeplearning.ai/t/can-anyone-help-where-is-the-mistake-ml-course-c3-w2/178754/3 "2022-08-05T18:06:37Z")

</div>

Got it! Thank you very much!

---

<div class="post-metadata">

**Author:** ![Hasham\_Akram](https://avatars.discourse-cdn.com/v4/letter/h/aeb1de/32.png) [@Hasham\_Akram](https://community.deeplearning.ai/u/Hasham_Akram)\
**Post date:** [February 22, 2024, 7:33am UTC](https://community.deeplearning.ai/t/can-anyone-help-where-is-the-mistake-ml-course-c3-w2/178754/4 "2024-02-22T07:33:28Z")

</div>

![Screenshot 2024-02-22 122636](https://global.discourse-cdn.com/dlai/original/3X/3/a/3aa43a8a87ee9247037ccd6b3b28cb35c056e356.png)  
Hey! hopw you all doing fine, I’m getting this error in test case, can anyone suggest me what is going wrong depite the code produces the same expected values, I’m getting confused about it. i cant even change the atol to higher accuracy in testcasefiles.
