Dear Community,
I am also struggling a bit with this weekâs assignment and i would like to ask for some help.
i think i have a quite complex problem, let me start explaining.
First I also had this same problem, when cost function does not decreasing. Moreover i have b values still 0âŚ
Cost after iteration 0: 0.692686
Cost after iteration 1000: 0.692686
Cost after iteration 2000: 0.692686
Cost after iteration 3000: 0.692686
Cost after iteration 4000: 0.692686
Cost after iteration 5000: 0.692686
Cost after iteration 6000: 0.692686
Cost after iteration 7000: 0.692686
Cost after iteration 8000: 0.692686
Cost after iteration 9000: 0.692686
W1 = [[0.00550798 0.00708148]
[0.00290905 0.00510828]
[0.00892947 0.00896293]
[0.00125585 0.00207243]]
b1 = [[0.]
[0.]
[0.]
[0.]]
W2 = [[0.00051467 0.0044081 0.00029876 0.00456833]]
b2 = [[0.]]
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-20-1243cded3c7d> in <module>
----> 1 nn_model_test(nn_model)
~/work/release/W3A1/public_tests.py in nn_model_test(target)
292 assert output["b2"].shape == expected_output["b2"].shape, f"Wrong shape for b2."
293
--> 294 assert np.allclose(output["W1"], expected_output["W1"]), "Wrong values for W1"
295 assert np.allclose(output["b1"], expected_output["b1"]), "Wrong values for b1"
296 assert np.allclose(output["W2"], expected_output["W2"]), "Wrong values for W2"
AssertionError: Wrong values for W1
So i started troubleshooting backwards, taking a look at update function.
The more interesting is that in the update function the returned b2 value has some not appropriate dimenson and i dont know where it comes from.
W1 = [[-0.00643025 0.01936718]
[-0.02410458 0.03978052]
[-0.01653973 -0.02096177]
[ 0.01046864 -0.05990141]]
b1 = [[-1.02420756e-06]
[ 1.27373948e-05]
[ 8.32996807e-07]
[-3.20136836e-06]]
W2 = [[-0.01041081 -0.04463285 0.01758031 0.04747113]]
b2 = [[1.21732533e-05]
[2.12263977e-05]
[1.36755874e-05]
[1.05251698e-05]]
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-22-c37f65e5c916> in <module>
7 print("b2 = " + str(parameters["b2"]))
8
----> 9 update_parameters_test(update_parameters)
~/work/release/W3A1/public_tests.py in update_parameters_test(target)
245 assert output["b1"].shape == expected_output["b1"].shape, f"Wrong shape for b1."
246 assert output["W2"].shape == expected_output["W2"].shape, f"Wrong shape for W2."
--> 247 assert output["b2"].shape == expected_output["b2"].shape, f"Wrong shape for b2."
248
249 assert np.allclose(output["W1"], expected_output["W1"]), "Wrong values for W1"
AssertionError: Wrong shape for b2.
Although i hope i implemented the right recall operations like:
W1 = copy.deepcopy(parameters["W1"])
...
dW1 = grads["dW1"]
and learning rate determinition
W1 = W1 - learning_rate * dW1
...
So I went back to init parameters and found that even the random initialization is not correct
W1 = [[0.00435995 0.00025926]
[0.00549662 0.00435322]
[0.00420368 0.00330335]
[0.00204649 0.00619271]]
b1 = [[0.]
[0.]
[0.]
[0.]]
W2 = [[0.00299655 0.00266827 0.00621134 0.00529142]]
b2 = [[0.]]
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-10-0eb4c3a6d62e> in <module>
8 print("b2 = " + str(parameters["b2"]))
9
---> 10 initialize_parameters_test(initialize_parameters)
~/work/release/W3A1/public_tests.py in initialize_parameters_test(target)
57 assert parameters["b2"].shape == expected_output["b2"].shape, f"Wrong shape for b2."
58
---> 59 assert np.allclose(parameters["W1"], expected_output["W1"]), "Wrong values for W1"
60 assert np.allclose(parameters["b1"], expected_output["b1"]), "Wrong values for b1"
61 assert np.allclose(parameters["W2"], expected_output["W2"]), "Wrong values for W2"
AssertionError: Wrong values for W1
after the random.rand(n_h, n_y) * 0.01 how is it even possible that these random numbers are not accepted?
I would appreciate some explanational comments.
Hope the equations in codes inserted doesnât mean any problem.
Regards