Tensorflow您必须使用dtype float为占位符张量'p'提供值

时间:2017-12-14 07:22:09

标签: python-3.x tensorflow tensorflow-gpu

我正在使用mnist数据来查看tf.train.shuffle_batch是如何工作的,我收到了这个错误

  

InvalidArgumentError(请参阅上面的回溯):您必须使用dtype float为占位符张量'p'提供值        [[节点:p = Placeholderdtype = DT_FLOAT,shape = [],_ device =“/ job:localhost / replica:0 / task:0 / gpu:0”]]        [[Node:Slice / _1 = _Recvclient_terminated = false,recv_device =“/ job:localhost / replica:0 / task:0 / cpu:0”,send_device =“/ job:localhost / replica:0 / task:0 / gpu :0“,send_device_incarnation = 1,tensor_name =”edge_7_Slice“,tensor_type = DT_FLOAT,_device =”/ job:localhost / replica:0 / task:0 / cpu:0“]]

但是我确实用dtype float给'p'占位符提供了一个值,所以我不知道为什么我会收到这个错误

这是我的代码:

mnist = input_data.read_data_sets('../../MNIST_data', one_hot=True)
img = mnist.train.images
print(type(img))
print(img.shape)
p = tf.placeholder(tf.float32, [None, 784], name='p')
img_batch = tf.train.shuffle_batch([tf.slice(p, [np.random.randint(55000), 0], [1, -1])], 9, 130, 100)
with tf.Session() as sess:
    threads = tf.train.start_queue_runners(sess=sess)
    img_b = sess.run(img_batch, feed_dict={p: mnist.train.images})

0 个答案:

没有答案