Week 1 , Assignment 1, Ex 1. Unexpected shape of x_pad

Hi ,

I just started working on Assignment 1 in week one of DLS4 course. Where we write the zero pading function. According to the function specs I need to return the X_pad as

   Returns:
    X_pad -- padded image of shape (m, n_H + 2 * pad, n_W + 2 * pad, n_C)

And this is exactly what I did. However the function is failing the result even tough I think it is with the correct size with respect to its import. Further more I think the shape that the test is expecting is strange. especially that it is expecting that I change the first dimension ( number of examples) and the last dimension ( channel size) which should not be the case. it looks like the shape is increased by (1,1,1,1)

below is the actual error :

 X= ,  (4, 3, 3, 2)
2
X_pad,  (4, 7, 7, 2)
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-3-a6f364884ebb> in <module>
     12 axarr[1].set_title('x_pad')
     13 axarr[1].imshow(x_pad[0, :, :, 0])
---> 14 zero_pad_test(zero_pad)

~/work/release/W1A1/public_tests.py in zero_pad_test(target)
     27 
     28     assert type(x_pad) == np.ndarray, "Output must be a np array"
---> 29     assert x_pad.shape == (5, 4 + 2 * pad, 4 + 2 * pad, 3), f"Wrong shape: {x_pad.shape} != {(5, 4 + 2 * pad, 4 + 2 * pad, 3)}"
     30     assert np.allclose(x_pad[0, 0:2,:, 0], [[0, 0, 0, 0, 0, 0, 0, 0], 
     31                                             [0, 0, 0, 0, 0, 0, 0, 0]], 1e-15), "Rows are not padded with zeros"

AssertionError: Wrong shape: (4, 7, 7, 2) != (5, 8, 8, 3)

Please help

thanks

Turns out I was referencing a global variable when creating the shape. This created inconsistency issues when testing

Thanks for your report.

Same issue here. Thanks a lot!