I had the same issue, and followed wmrkwok’s instructions to get a fresh copy of the assignment. It fixed my issue and I got 100% after re submitting the code.
There is more than one cause for this issue.
For example, the Hint code has whitespace formatting errors, so if you copy-and-paste it into the function code, it can have very odd problems.
I’m getting this error message on same lab.
Gradient at initial w, b (zeros): -0.04747762052631062 -0.007323908939747608
Using X with shape (4, 1)
AssertionError Traceback (most recent call last)
in
6 print(‘Gradient at initial w, b (zeros):’, tmp_dj_dw, tmp_dj_db)
7
----> 8 compute_gradient_test(compute_gradient)
~/work/public_tests.py in compute_gradient_test(target)
60 dj_dw, dj_db = target(x, y, initial_w, initial_b)
61 #assert dj_dw.shape == initial_w.shape, f"Wrong shape for dj_dw. {dj_dw} != {initial_w.shape}"
—> 62 assert dj_db == -2, f"Case 2: dj_db is wrong: {dj_db} != -2"
63 assert np.allclose(dj_dw, -10.0), f"Case 1: dj_dw is wrong: {dj_dw} != -10.0"
64
AssertionError: Case 2: dj_db is wrong: -0.6640625 != -2
Should I reboot the lab?
Same here. Easy to fix with proper indentation.
@ilsa, have you fixed the issue?
THAT one yes thanks!
Now on Week 3 Lab Logistic Regression
Getting this error message:
NameError Traceback (most recent call last)
in
4 initial_w = np.zeros(n)
5 initial_b = 0.
----> 6 cost = compute_cost(X_train, y_train, initial_w, initial_b)
7 print(‘Cost at initial w and b (zeros): {:.3f}’.format(cost))
NameError: name ‘compute_cost’ is not defined
Expected Output:
Cost at initial w and b (zeros) 0.693
Every time you load a notebook, you have to run all of the cells starting from the top.
dj_db at test w and b: -0.1
dj_dw at test w and b: [-0.3738794650046383, -0.4476490644756638]
AssertionError Traceback (most recent call last)
in
8
9 # UNIT TESTS
—> 10 compute_gradient_test(compute_gradient)
~/work/public_tests.py in compute_gradient_test(target)
51 dj_db, dj_dw = target(X, y, test_w, test_b)
52
—> 53 assert np.isclose(dj_db, 0.28936094), f"Wrong value for dj_db. Expected: {0.28936094} got: {dj_db}"
54 assert dj_dw.shape == test_w.shape, f"Wrong shape for dj_dw. Expected: {test_w.shape} got: {dj_dw.shape}"
55 assert np.allclose(dj_dw, [-0.11999166, 0.41498775, -0.71968405]), f"Wrong values for dj_dw. Got: {dj_dw}"
AssertionError: Wrong value for dj_db. Expected: 0.28936094 got: -0.07142857142857142
Any thoughts?
Errors in this function are often caused by indentation errors. Python uses indentation to define blocks of code.
Using for-loops can be rather tricky.