There is the example of tensorflow.pad():
# 't' = is [[1, 2, 3], [4, 5, 6]].
# 'paddings' is [[1, 1,], [2, 2]].
# rank of 't' is 2.
' tf.pad(t, paddings, "CONSTANT")'
==> [[0, 0, 0, 0, 0, 0, 0],[0, 0, 1, 2, 3, 0, 0],[0, 0, 4, 5, 6, 0, 0],[0, 0, 0, 0, 0, 0, 0]]
my question is how to pad zeros in every dimention of input? And the shape of t is [2,3], why output after pad() is [4,x],how the '4' comes?
Thanks for helping me!!!
'paddings' is [[1, 1,], [2, 2]]. Try to map this vale us as [[top,bottom],[left,right]].
i.e.
top = 1, //Extra padding introduce on top
bottom = 1, //Extra padding introduce on bottom
left = 2, //Extra padding introduce on left
right = 2. //Extra padding introduce on right
Try another example where 'padding' is [[2, 1], [2, 3]].
Output will be:
[[0 0 0 0 0 0 0 0][0 0 0 0 0 0 0 0][0 0 1 2 3 0 0 0][0 0 4 5 6 0 0 0][0 0 0 0 0 0 0 0]]
Here top=2, bottom=1, left=2, right=3.