Course 4 Week 2 Asst 1

Getting assertion error.

Performed the steps as depicted in the picture.

Step 1: X_shortcut = X
Step 2: Computed First component of main path - Conv2D, BatchNorm, Relu with X as the input, filter = F1. Stride = (1,1), padding = ‘valid’
Step 3: Computed Second component of main path - Conv2D, BatchNorm, Relu with X as the input, filter = F2. Stride = (1,1), padding = ‘same’
Step 4: Computed Third component of main path - Conv2D, BatchNorm with X as the input, filter = F3. Stride = (1,1), padding = ‘valid’
Step 5: Added X_shortcut with X and assigned to X
Step 6: Computed Relu with the output of Step 5

Getting the following error:

With training=False

[[[ 0. 0. 0. 0. ]
[ 0. 0. 0. 0. ]]

[[ 48.92808 48.92808 48.92808 48.92808]
[ 48.92808 48.92808 48.92808 48.92808]]

[[146.78426 146.78426 146.78426 146.78426]
[146.78426 146.78426 146.78426 146.78426]]]
48.928085

With training=True

[[[0. 0. 0. 0. ]
[0. 0. 0. 0. ]]

[[0.29298 0.29298 0.29298 0.29298]
[0.29298 0.29298 0.29298 0.29298]]

[[4.41404 4.41404 4.41404 4.41404]
[4.41404 4.41404 4.41404 4.41404]]]

AssertionError Traceback (most recent call last)
in
22 print(np.around(A4.numpy()[:,(0,-1),:,:].mean(axis = 3), 5))
23
—> 24 public_tests.identity_block_test(identity_block)

/tf/W2A1/public_tests.py in identity_block_test(target)
25 resume = A3np[:,(0,-1),:,:].mean(axis = 3)
26
—> 27 assert np.floor(resume[1, 0, 0]) == 2 * np.floor(resume[1, 0, 3]), “Check the padding and strides”
28 assert np.floor(resume[1, 0, 3]) == np.floor(resume[1, 1, 0]), “Check the padding and strides”
29 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

Triple checked my implementation of identity_block. Seems correct to me.

But still getting this error.

1 Like

My issue was due to the kernel shape. Fixed it.

1 Like