I am having difficulty in implementing zero_padding function.
inside the np.pad, I put my argument X and use tuple to put my height and width as ((2p,2p), (2p,2p). I looked at the documentation and worked on this for couple of hours but still can’t get it correct.
I think I am setting the pad_width wrong but tried many things and still doesn’t work.
Hi @Malik_Shavkatov ,
You need only pay attention to the example. Then check the argument and return values in the function to know what to do.
Thank you for responding. I am not sure what you mean.
I know the return values and saw the example. X contains two channels, therefore I have 2 tuples, each representing each channel. The np.pad should return the same array shape as the input?
I am sending you the code. Thanks!
Note that the comment in the returns shows the format of the shape and which dimensions of the shape to apply the pad. So, you only need to use the example and the tips to get the correct output.
Thank you @carlosrl ,
I got it fixed but still confused on the application of the padding. I am assuming now that np.pad automatically pads each channel of the image?
Note that when we check the output tip, we can see that padding is affecting only height and width and not channel. But, yes, you can pass a value to np.pad() to be padded to channels.