我有一个输入占位符:
Y = tf.placeholder(dtype=tf.float32, shape=(None, n_outputs))
现在我想创建一个与 Y 形状相同的常量:
w = Y.get_shape()
zero = tf.constant(np.zeros(w), dtype=tf.float32)
错误返回:
__index__ returned non-int (type NoneType)
最佳答案
在另一篇文章中找到了答案 tensorflow-constant-with-variable-size
zero = tf.fill(tf.shape(Y), 0.0)
关于python - tensorflow :如何创建一个与占位符形状相同的常量张量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47674588/