Is it possible that there are errors in the testing of the optional exercises?
Firstly, I have re-written the function: def conv_backward(dZ, cache)
a couple of times after re-reading, the instructions and drawing matrix diagrams of the layer and always come to the same solution. However, the test always gives the following error:
dA_mean = 1.457943469708148
dW_mean = 1.7519334429380524
db_mean = 7.259465017141471
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-109-3575597a0654> in <module>
22 assert dW.shape == (2, 2, 3, 8), f"Wrong shape for dW {dW.shape} != (2, 2, 3, 8)"
23 assert db.shape == (1, 1, 1, 8), f"Wrong shape for db {db.shape} != (1, 1, 1, 8)"
---> 24 assert np.isclose(np.mean(dA), 1.4524377), "Wrong values for dA"
25 assert np.isclose(np.mean(dW), 1.7269914), "Wrong values for dW"
26 assert np.isclose(np.mean(db), 7.8392325), "Wrong values for db"
AssertionError: Wrong values for dA
Secondly, exercise 7, def distribute_value(dz, shape)
returns a 2x2 matrix in the test. Each element in a 4-element matrix should be multiplied be 0.25 to get the average values of the matrix, as evidenced in the instructions. However, the test expects each element of the this matrix to be 0.5. That would be the averaging factor for a 2-element matrix. Below is the error message with my own print statements of the input values, and resulting matrix and shape:
Student_print: n_H:2, n_W:2, average:4
Student_print: [[0.25 0.25]
[0.25 0.25]] (2, 2)
distributed value = [[0.25 0.25]
[0.25 0.25]]
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-125-06680df7c38d> in <module>
5 assert type(a) == np.ndarray, "Output must be a np.ndarray"
6 assert a.shape == (2, 2), f"Wrong shape {a.shape} != (2, 2)"
----> 7 assert np.sum(a) == 2, "Values must sum to 2"
8
9 a = distribute_value(100, (10, 10))
AssertionError: Values must sum to 2
Note the expected shape (2,2) and expected sum (2). I think the expected sum should be 1. Shouldn’t it always be 1?
Any comments or hints would be appreciated.