【发布时间】:2016-03-19 18:52:49
【问题描述】:
我的代码曾经在 tensorflow 0.6 上运行,但它不再适用于最新的 tensorflow。
我想每隔几次训练迭代执行一次推理。我的训练数据来自队列,我的推理数据来自 feed_dict。训练批次大小为 128,推理批次大小为 1。我应该怎么做才能让网络接受这两种不同的批次大小?
batch_size = 128
x_batch = tf.placeholder("float", [None, 100])
q = tf.FIFOQueue(10, [tf.float32], shapes=[[batch_size, 100]])
enqueue_op = q.enqueue([x_batch])
# during training
x = q.dequeue() # dequeue operation
# network definition, takes x as input, and output y
......
# during inference
x_array_of_batch_size_1 = .. # a 1x100 numpy array
sess.run([y], feed_dict={x: x_array_of_batch_size_1))
我收到以下错误:
ValueError: Cannot feed value of shape (1, 100) for Tensor u'fifo_queue_Dequeue:0', which has shape '(128, 100)'
【问题讨论】:
标签: python tensorflow training-data prefetch