I see many users have submitted the same problem.
While running this below I get the correct results:
Evaluate cost function
J = cofi_cost_func(X_r, W_r, b_r, Y_r, R_r, 0);
print(f"Cost: {J:0.2f}")
but then, when regularization is added on the next step - I get the same result as before without regularization:
Evaluate cost function with regularization
J = cofi_cost_func(X_r, W_r, b_r, Y_r, R_r, 1.5);
print(f"Cost (with regularization): {J:0.2f}")
and therefore with the next step, I get an error message:
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 0.0. Check the regularization term