作者:爱-雨轩_627 | 来源:互联网 | 2023-02-04 10:19
有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]]
我的问题是如何在每个输入维度中填充零?并且t的形状为[2,3],为什么pad()之后的输出为[4,x],“ 4”如何出现?感谢您的帮助!!!
1> vipin bansal..:
'paddings'是[[1,1,],[2,2]]。尝试将此谷歌映射为[[top,bottom],[left,right]]。即
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
尝试另一个示例,其中“填充”为[[2,1],[2,3]]。输出将是:
[[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]]
此处top = 2,bottom = 1,left = 2,right = 3。