【发布时间】:2017-10-11 13:07:17
【问题描述】:
基本上,我有一个函数需要一个张量 x 和两个占位符 z 和 c。
def error_robust(x,z,c):
zz = tf.reshape(z, [-1, 28, 28, 1])
var = tf.reduce_mean(x-zz)
out = tf.cond( tf.abs(var) <= c, lambda: (c*c/6.0)*(1 - tf.pow(1-tf.pow(var/c,2),3)), lambda: tf.Variable(c*c/6.0) )
return out
我定义了我要使用的占位符和张量:
# TENSORFLOW PLACEHOLDERS
sess = tf.Session(config=tf.ConfigProto(allow_soft_placement=True))
flat_mnist_data = tf.placeholder(tf.float32, [None, 28*28])
dropout_keep_prob = tf.placeholder(tf.float32)
param_robust = tf.placeholder(tf.float32, shape=())
调用定义的函数不会产生任何错误:
error_r = error_robust(layer1_b.reconstruction, flat_mnist_data, param_robust)
这会产生错误:
sess.run(tf.global_variables_initializer())
InvalidArgumentError(请参阅上面的回溯):您必须为占位符张量“Placeholder”提供一个 dtype float 的值 [[节点:Placeholder = Placeholderdtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/gpu:0"]]
我真的不明白为什么会这样。关于如何解决这个问题的任何想法?
【问题讨论】:
标签: tensorflow