C3_W2_Collaborative_RecSys_Assignment - Regularization?

Hi,

So I have tried many ways at this point and still cannot pass the tests with the regularization term added on.

I am looking for some assistance in where I might be going wrong.

I don’t want to post code here with it being an assignment but really need help.

Thanks.

1 Like

Hi!

Can you send me your code in a direct message?

Hi, I have the same issue. I have implemented the regularization like this:

        reg_term = (lambda_/2) * (np.sum(np.square(W)) + np.sum(np.square(X)))
        J+= np.square(r * (np.dot(w,x) + b_j - y)) + reg_term

But I still keep getting this error while performing the test:

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

Does anyone have a solution for this?

Thanks!

1 Like

Hi @Igor_Kalin ,

Is your regularization term in the loop for calculating the cost function?
The regularization terms only need to be calculated once and added at the end.

1 Like

Hi @SamReiswig,

Thank you for your answer. The issue was that the regularization term was placed inside of a loop. This is my final code and now everything works fine:

~ {mentor edit: removed code / solution to assignment} ~

Wow, it took me a long time to figure this out as well! Perhaps the description cell 4.1 should include some extra parentheses in the equation for clarity?

thank you very much, it worked