# Zero_pad function( course 4, Week 1, exersice 1)

I have a problem with defining the zero_pad function to be precise the X_pad value using the np.pad() function.
To define the pad_width I suppose to add 2 * pad_value in both directions horizontally and vertically, but when I saw the expected value in the next test cell it shows that the resulted image has zero paddings only along with its height, so the size for each image in the vector will be changed from (3,2) to (9,2) which is something I don’t understand, I expect to have (9,8) as a new size, assume the pad value to be 3.
Thanks for any help!

The zero pad function only adds padding to the 2nd and 3rd dimensions of the X 4D matrix. So each image becomes 9x9x2. That is what the test case shows.

1 Like

Thanks for the reply, but the problem still not solved, I keep having the dimension of (4, 9, 9, 8) and I don’t know why.
this is what I used inside for loop and then concatenate padded images in one array.

You have only added padding for one dimension. The instructions tell you to add padding for the 2nd and 3rd dimensions. So you have to skip the 1st and 4th dimensions and use (pad,pad) for both the 2nd and 3rd.