I tried to practice zero-padding outside of the programing assignment.
As an example, I wrote
A=np.array
([[[ 0, 1, 2],
[ 3, 4, 5],
[ 6, 7, 8]],
[[ 9, 10, 11],
[12, 13, 14],
[15, 16, 17]],
[[18, 19, 20],
[21, 22, 23],
[24, 25, 26]]])
I tried to pad everything with padding=1, so I wrote
B=np.pad(A, ((1,1), (1,1), (0,0)),‘constant’)
But it didn’t work out as expected.
Only
B=np.pad(A, ((0,0), (1,1), (1,1)),‘constant’)
yielded the wanted output (below) Why is that so?
([[[ 0, 0, 0, 0, 0],
[ 0, 0, 1, 2, 0],
[ 0, 3, 4, 5, 0],
[ 0, 6, 7, 8, 0],
[ 0, 0, 0, 0, 0]],
[[ 0, 0, 0, 0, 0],
[ 0, 9, 10, 11, 0],
[ 0, 12, 13, 14, 0],
[ 0, 15, 16, 17, 0],
[ 0, 0, 0, 0, 0]],
[[ 0, 0, 0, 0, 0],
[ 0, 18, 19, 20, 0],
[ 0, 21, 22, 23, 0],
[ 0, 24, 25, 26, 0],
[ 0, 0, 0, 0, 0]]])