When I included the regularization term the first test works fine but when I comment it out it fails with
AssertionError: Wrong value. Expected 27, got 0.0. Check the regularization term
But the instructions say
First, develop the cost function without regularization. A test case that does not include regularization is provided below to test your implementation.
run the test of the cofi_cost_func with the regularization term and print out the error (if the regularization term is missing), while the function that is below:
Yes, you are correct. I did not say that we have to do it it was rather a suggestion for the course administrators that they can change it in the future version of this assignment.
You can skip the first function test_cofi_cost_func and run it later after you add the regularization term to your cofi_cost_func function. Or if you run it earlier then just run it again to get rid of that error. It is a test function and it only checks if your code is correct.
My previous post was an explanation of the source of that error.
I believe one of the issues is the first assert in test_cofi_cost_func will always trigger and return 0 without the regularization term because R_r is an array of zeros.
I too got: “Wrong value. Expected 27, got 0.0” and I was pulling my hair out, and it wasn’t until I copy & pasted the exact code from the hints and saw it still had that same error that I came looking on the forum.
I had to figure out & include the regularization in my code for it to work.
Hi Nathan @evoalg, I am sorry to hear about that. Wendy had reported this issue, and i also tried to draw the course team’s attention about this again. Now I think the team is reprioritizing this but it may take some time because any change has to be carefully reviewed in order not to break something else down. Lastly, I want to say thank you for letting us hear your voice.
Thank you, Raymond, good to hear it’s being actioned. I just didn’t want others to go through that (thinking they were doing something wrong). It’s a wonderful course and loverly mentors and that was the only hiccup that I’ve encountered.
No problem Nathan. We are the same - we both don’t want others to go through that. I look forward to discussing with you on other questions about the last course, of course if there is any
I also faced the same problem too I tried to solve it, but I got the same error every time. However, I will skip the lab and pass on to the next topic until the team fix the problem!
The team has made a change that will automatically apply to all new learners. For existing learners, however, they will only see the change if they manually get a new copy of the notebook.
The change is basically to reorder the testing cells so that
the tests for without-regularization will come first,
followed by the tests for with-regularization,
and lastly the public tests for with-regularization.
Here is how we can do to proceed:
Since the change is only about reordering the cells, you may choose not to update the lab, but run the cells in the right order. I am sharing a screenshot of the right order here:
If you want to update the lab, you may follow these steps which will ask you to rename your current notebook so that the system can give you a new one. Then you may copy your work from your current notebook back to the new one.
Lastly, these changes DO NOT change the requirement that you need to add regularization to the cofi_cost_func after passing the without-regularization tests, in order to pass the rest of the tests.
Cheers,
Raymond
P.S. I am making this post the solution so that others can quickly jump to here.
Unfortunately, I’m still stuck on the same error. However, I followed your guidelines and still face the same problem where I got Cost (with regularization): 144.23 not as expected 28.
Why do you comment out the line that actually calculate the cost? I would have understood it if you commented out the line next to it for the without-regularization test, but for the one you actually commented out, I cannot understand.
You only need to add the regularization once, not per user and per movie. Check out the formula above the exercise, and you will see that the “regularization part” does not belong to the summations (because there is no brackets)
Regularization needs only one divided by 2. Becareful about this.
We don’t post assignment code here, so I am removing it.
Sorry but I have to close this thread since the discussion starts to derivate from the original topic. Please open a new thread, share the error messages if you have any follow-up question.