Hi, I am trying to complete week 2 assignment 1, which seems like a pretty simple use of Keras. But, I consistently get a test failing on both of the first two graded blocks.
Below are the failing tests. I have checked and rechecked the stride and filter parameters and they seem to match what is expected in the description. One question is – I don’t see a use for the f parameter to the function, as the filter specifications are provided separately in F1, F2, F3 but is there some use for f that I am missing that’s actually causing this?
Function 1
AssertionError Traceback (most recent call last)
Input In [4], in <cell line: 30>()
26 A4 = identity_block(X, f=2, filters=[3, 3, 3],
27 initializer=lambda seed=0:constant(value=1))
28 print(np.around(A4.numpy()[:,(0,-1),:,:].mean(axis = 3), 5))
---> 30 public_tests.identity_block_test(identity_block)
File /tf/W2A1/public_tests.py:31, in identity_block_test(target)
28 assert np.all(A3np >= 0), "The ReLu activation at the last layer is missing"
29 resume = A3np[:,(0,-1),:,:].mean(axis = 3)
---> 31 assert np.floor(resume[1, 0, 0]) == 2 * np.floor(resume[1, 0, 3]), "Check the padding and strides"
32 assert np.floor(resume[1, 0, 3]) == np.floor(resume[1, 1, 0]), "Check the padding and strides"
33 assert np.floor(resume[1, 1, 0]) == 2 * np.floor(resume[1, 1, 3]), "Check the padding and strides"
AssertionError: Check the padding and strides
Function 2
tf.Tensor(
[[[0. 0. 0. 0. 0.10979614 0. ]
[0. 0. 0. 0. 0.10979614 0. ]]
[[0. 0. 0. 0. 0.10979614 0. ]
[0. 0. 0. 0. 0.10979614 0. ]]], shape=(2, 2, 6), dtype=float32)
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
Input In [5], in <cell line: 3>()
1 ### you cannot edit this cell
----> 3 public_tests.convolutional_block_test(convolutional_block)
File /tf/W2A1/public_tests.py:115, in convolutional_block_test(target)
112 tf.keras.backend.set_learning_phase(True)
114 C = target(X, f = 2, filters = [2, 4, 6])
--> 115 assert np.allclose(C.numpy(), convolutional_block_output2), "Wrong values when training=True."
117 print('\033[92mAll tests passed!')
AssertionError: Wrong values when training=True.
Thanks, Jeff