简述
tf中的zeros()可以生成指定形状的数值为0的tensor.
tf中的ones()可以生成指定形状的数值为1的tensor.
tf中的fill()可以生成指定形状的指定数值的tensor.
代码
import tensorflow as tf
a = tf.zeros([2, 3])
b = tf.ones([2, 3])
c = tf.fill([2, 3], 9)
a = tf.zeros((2, 3))
b = tf.ones([2, 3])
c = tf.fill([2, 3], 9)
print("a: ", a)
print("b: ", b)
print("c: ", c)