# Test cofi\_cost\_fun in Lab 1 week2 of MLS course 3

**URL:** <https://community.deeplearning.ai/t/test-cofi-cost-fun-in-lab-1-week2-of-mls-course-3/228148>\
**Category:** Unsupervised Learning, Recommenders, Reinforcement\
**Tags:** week-module-2\
**Created:** [November 8, 2022, 9:48am UTC](https://community.deeplearning.ai/t/test-cofi-cost-fun-in-lab-1-week2-of-mls-course-3/228148 "2022-11-08T09:48:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Onuorah\_Martins\_Onye](https://avatars.discourse-cdn.com/v4/letter/o/c5a1d2/32.png) [@Onuorah\_Martins\_Onye](https://community.deeplearning.ai/u/Onuorah_Martins_Onye)\
**Post date:** [November 8, 2022, 9:48am UTC](https://community.deeplearning.ai/t/test-cofi-cost-fun-in-lab-1-week2-of-mls-course-3/228148/1 "2022-11-08T09:48:33Z")

</div>

Hello my Mentors, I thank you all for working on us to complete our assignment.  
I was able to get the cost with and without regularization.  
But my cofi\_cost\_fun test 1 failed. Below is the error massage.  
Please assist.  
AssertionError Traceback (most recent call last)  
 in   
1 # Public tests  
2 from public\_tests import \*  
----\> 3 test\_cofi\_cost\_func(cofi\_cost\_func)

~/work/public\_tests.py in test\_cofi\_cost\_func(target)  
14 J = target(X\_r, W\_r, b\_r, Y\_r, R\_r, 2);  
15 assert not np.isclose(J, 13.5), f"Wrong value. Got {J}. Did you multiply the regularization term by lambda\_?"  
—\> 16 assert np.isclose(J, 27), f"Wrong value. Expected {27}, got {J}. Check the regularization term"  
17  
18

AssertionError: Wrong value. Expected 27, got 540.0. Check the regularization term

Vectorized Implementation

---

<div class="post-metadata">

**Author:** ![jenitta.jebaraj](https://avatars.discourse-cdn.com/v4/letter/j/cdc98d/32.png) [@jenitta.jebaraj](https://community.deeplearning.ai/u/jenitta.jebaraj)\
**Post date:** [November 8, 2022, 1:26pm UTC](https://community.deeplearning.ai/t/test-cofi-cost-fun-in-lab-1-week2-of-mls-course-3/228148/2 "2022-11-08T13:26:00Z")

</div>

Hello @Onuorah_Martins_Onye

Check the indentation of regularization term and check the following post also…

> [@C3\_W2\_Collaborative\_RecSys\_Assignment: Exercise 1 errors](https://community.deeplearning.ai/t/c3-w2-collaborative-recsys-assignment-exercise-1-errors/176175/8):
>
> I am getting the same error in Exercise1 - Here is the code: # GRADED FUNCTION: cofi\_cost\_func # UNQ\_C1 def cofi\_cost\_func(X, W, b, Y, R, lambda\_) ======== While running the below code getting error- Public tests from public\_tests import \* test\_cofi\_cost\_func(cofi\_cost\_func) ========= AssertionError Traceback (most recent call last) in 1 # Public tests 2 from public\_tests import \* ----\> 3 test\_cofi\_cost\_func(cofi\_cost\_func) ~/work/public\_tests.py in t…

> [@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/5):
>
> AssertionError: Wrong value. Expected 27, got 540.0. Check the regularization term how to solve this?

---

<div class="post-metadata">

**Author:** ![Onuorah\_Martins\_Onye](https://avatars.discourse-cdn.com/v4/letter/o/c5a1d2/32.png) [@Onuorah\_Martins\_Onye](https://community.deeplearning.ai/u/Onuorah_Martins_Onye)\
**Post date:** [November 8, 2022, 1:53pm UTC](https://community.deeplearning.ai/t/test-cofi-cost-fun-in-lab-1-week2-of-mls-course-3/228148/3 "2022-11-08T13:53:34Z")

</div>

Thanks Jenitta.

I will check all that you have mentioned
