Hi there! I cannot understand where is the problem. Thx!
I read another topics with similar problem but I can’t get the reason…
Hi there! I cannot understand where is the problem. Thx!
I read another topics with similar problem but I can’t get the reason…
Hi @Marc_Oliveras ,
Please double-check if you have correctly implemented the regularization term in the function cofi_cost_func()
. You are getting the same cost even when passing the regularization.
Hi @Mujassim_Jamal , I don’t understand you. I can’t change this formula because it comes by default from the assignment.
You don’t have to change anything in the cells where the evaluation is happening. The problem lies in the cofi_cost_func()
function in the Exercise 1 section of this assignment. Please make sure whether you have added regularized cost at the end in the function or not.
Hi @Mujassim_Jamal ,
Got it! Thx!
Hi Marc, I am having the same issue as you. Would you be able to share a screenshot of how you fixed it? I would be grateful. Thank you
Do not post your code on forums as it violates the code of conduct.
Hii there! After adding regularization term as mentioned in the formula, I am getting cost with regularization as 157.90. I am unable to fix the issue. Please help me with this soon. Thanks.
Sounds like you made a mistake in implementing the regularized term.
Can I share screenshot? It’s correct as per my knowledge.
Click on my profile and send it to me via DM.
this is what I get too even if I just use what was provided in hints.
It says that “Note that you should be accumulating the cost for user 𝑗 and movie 𝑖 only if 𝑅(𝑖,𝑗)=1.” I interpreted this as if R[i,j] == 1:
, and then my code. This made me get 20.88 on the “# Evaluate cost function with regularization” code block. If I take this out, I also get 157.90. What should I do?
Hello @BrunoPup115,
You are not the first one to ask about 157.9. Based on that, I would suggest you to check out the formula again. There are two square brackets, and we finish computing the first one, and then we compute the next, and then we add the two up. We don’t mix them up.
Raymond
PS: rule is rule, so I still need to edit your post to remove that
If you planned to FINISH the first bracket, and then FINISH the second bracket, and then sum them up, there should have been three steps only. However, interestingly, from your prints, you had four steps. Why don’t you literally FINISH one bracket at a time, such that after the sum, you won’t do any additional thing?
I can’t tell you where the bug is since it’s your problem to solve. My suggestion is, for that exercise,
Let’s see what will happen.
Raymond
PS1: My steps 1 to 3 are one general way to get out from a code trap set up by our own belief that our code is correct or reasonable, when nobody can tell us the answer. It works better if we can give ourselves a break before starting, so that we can refresh ourselves.
I looked at the hint, and that helped, so now I am getting the “Evaluate cost function with regularization
” block correct, but on the “Public test
” block, it says
AssertionError Traceback (most recent call last)
<ipython-input-55-1b3acfa244cb> in <module>
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 0.0. Check the regularization term
(See attached image)
Nevermind. I figured it out.
I have been getting this error. I have infact re-written the code multiple times, checked the indentation and still could not get it working. Can you please let me know how you solved this?