【发布时间】:2018-04-29 23:41:52
【问题描述】:
我的代码是这样写的。
def __init__(self, X):
ops.reset_default_graph()
tl.layers.clear_layers_name()
self.sess = tf.Session()
self.input_x = tf.placeholder(tf.float32, shape=[None, 784],name="input")
input_layer = tl.layers.InputLayer(self.input_x)
drop1 = tl.layers.DropoutLayer(input_layer, keep=0.8, name="drop1")
relu1 = tl.layers.DenseLayer(drop1, n_units=800, act = tf.nn.relu)
drop2 = tl.layers.DropoutLayer(relu1, keep=0.5, name="drop2")
self.output = drop2.all_layers[-1]
self.gradient = tf.gradients(self.output,self.input_x)
init_op = tf.initialize_all_variables()
self.sess.run(init_op)
self.output.eval(session=self.sess, feed_dict={self.input_x:X})
如您所见,只有一个占位符已启动,但是,我遇到了
InvalidArgumentError:您必须为占位符张量提供一个值 'Placeholder' 与 dtype 浮动 [[节点:占位符 = Placeholderdtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/cpu:0"]]
我百分百确定我输入的 X 的类型为 float32,形状为 [1000,784]。
【问题讨论】:
-
好像在
self.input_x以外的地方有占位符,你必须找到它。
标签: machine-learning tensorflow deep-learning