|
可以使用tensorflow.pad。但首先你必须使它成为二维张量。
indices = tf.constant([1,2,3,4])indices = tf.expand_dims(tf, 1) # now you have a (4,1)
tensorpadding = [[0,0],[0,1 # no padding before or after the first dimension
# no padding before second dimension. Single-element padding
# after the second dimension
my_goal = tf.pad(indices, padding, constant_values=6)
填充必须是[n,2]张量。有关更多信息,请查看:
https://www.tensorflow.org/api_docs/python/tf/pad.
|
|