我的代碼是這樣寫的。爲什麼在tensorflow中的這段代碼不起作用?
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: You must feed a value for placeholder tensor 'Placeholder' with dtype float [[Node: Placeholder = Placeholderdtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/cpu:0"]]
我百分之百肯定,我喂的X
具有類型FLOAT32,形狀[ 1000,784。
好像有佔位符除了'self.input_x'之外,你必須找到它。 –