How to overcome following error? Any guidance please.
Test your predict code
np.random.seed(1)
tmp_w = np.random.randn(2)
tmp_b = 0.3
tmp_X = np.random.randn(4, 2) - 0.5
tmp_p = predict(tmp_X, tmp_w, tmp_b)
print(f’Output of predict: shape {tmp_p.shape}, value {tmp_p}')
UNIT TESTS
predict_test(predict)
output and Error:
Output of predict: shape (4,), value [0. 0. 0. 1.]
AssertionError Traceback (most recent call last)
in
9
10 # UNIT TESTS
—> 11 predict_test(predict)
~/work/public_tests.py in predict_test(target)
69 raise ValueError(“Did you apply the sigmoid before applying the threshold?”)
70 assert result.shape == (len(X),), f"Wrong length. Expected : {(len(X),)} got: {result.shape}"
—> 71 assert np.allclose(result, expected_1), f"Wrong output: Expected : {expected_1} got: {result}"
72
73 b = -1.7
AssertionError: Wrong output: Expected : [1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0] got: [0. 0. 0. 0. 0. 0. 0. 1.]
Predict function looks like the following:
{mentor edit: code removed}