Python 使用tensorflow';s-shuffle\u批处理方法
我正在试验并尝试从Python 使用tensorflow';s-shuffle\u批处理方法,python,tensorflow,Python,Tensorflow,我正在试验并尝试从csv文件中读取数据,然后通过shuffle\u batch打印出一批数据。我已经把它扔掉了,但我还是不能让它工作 以下是我所拥有的: 导入tensorflow作为tf sess = tf.InteractiveSession() filename_queue = tf.train.string_input_producer( ["./data/train.csv"], num_epochs=1, shuffle=True) # total record count
csv
文件中读取数据,然后通过shuffle\u batch
打印出一批数据。我已经把它扔掉了,但我还是不能让它工作
以下是我所拥有的:
导入tensorflow作为tf
sess = tf.InteractiveSession()
filename_queue = tf.train.string_input_producer(
["./data/train.csv"], num_epochs=1, shuffle=True) # total record count in csv is 30K
reader = tf.TextLineReader()
key, value = reader.read(filename_queue)
record_defaults = [["1"], ["2"]] # irrelevant for this discussion
input, outcome = tf.decode_csv(value, record_defaults=record_defaults)
min_after_dequeue = 1000
batch_size = 10
capacity = min_after_dequeue + 3 * batch_size
example_batch = tf.train.shuffle_batch([outcome], batch_size, capacity, min_after_dequeue)
coord = tf.train.Coordinator()
tf.train.start_queue_runners(sess, coord=coord)
example_batch.eval(session = sess)
运行此操作将生成此异常:
OutOfRangeError: RandomShuffleQueue
'_3_shuffle_batch_1/random_shuffle_queue' is closed
and has insufficient elements (requested 10, current size 0)
我不确定是什么问题。我有一种感觉,这是由于会议和我处理它的方式;我可能做得不好 尝试从
string\u input\u producer
初始值设定项中删除num\u epochs=1
。“注意:如果num\u epochs不是None,此函数将创建本地计数器记录。使用本地变量\u初始值设定项()初始化本地变量。”请参阅发件人:yep,这是有效的。非常感谢。。。你能告诉我它背后的原因吗?param将队列限制为只遍历数据一次,因此我认为它已经没有足够的示例来填充队列了。可能数据的行数没有您想象的那么多(由一行或其他行隔开?)