wiln
September 8, 2024, 1:16am
1
I am doing the final test in week 3 course 1. I got the error:
~/work/public_tests.py in compute_cost_reg_test(target)
91 expected_output = target(X, y, w, b, lambda_)
92
—> 93 assert np.isclose(expected_output, 0.5469746792761936), f"Wrong output. Expected: {0.5469746792761936} got:{expected_output}"
94
95 w = np.random.randn(5)
AssertionError: Wrong output. Expected: 0.5469746792761936 got:0.5855062160376726
My compute_cost_reg function is:
{mentor edit: code removed
I can not find what is wrong in my code. I think it followed the formula well. Can anyone please help me?
TMosh
September 8, 2024, 5:05am
2
A reminder: Please do not post your code on the forum. The Code of Conduct does not allow it.
If a mentor needs to see your code, we’ll contact you with instructions.
Hint:
Inside your for-loop, if ‘w’ is a vector, you need to index it with ‘i’.
Kmewes
October 1, 2024, 6:33pm
3
I’m getting this error when trying to define the y train. I’ve tried to remove the periods and it doesn’t seem to help. For the second exercise
TMosh
October 1, 2024, 6:34pm
4
Try separating the elements with commas. That’s the syntax for creating a list in Python.
TMosh
October 1, 2024, 6:35pm
5
But I do not think you are supposed to create your own array for y_train.
Within the functions, the local variable name is ‘y’.
Kmewes
October 1, 2024, 6:45pm
6
I’ve taken away the variables but now im left with this error and im nit sure what it is referring to No worries if I’ve asked to much already thank you for your help!
TMosh
October 1, 2024, 6:49pm
7
It means either the variables i or j have an incorrect value.