在训练启动多线程时候报错RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed
,
原因是线程数不够,设置为32/64/128等如下:
在读取tfrecord时:
img_batch = tf.train.shuffle_batch([img, ],
batch_size=batch_size,
num_threads = 32,
capacity=10,
min_after_dequeue=1)
在训练文件中读取训练数据:
content_batch = get_content_tfrecord(batch_size, os.path.join(path_data, dataset_name), img_h)
然后在会话中开启多线程:
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(sess=sess, coord=coord)
之后就可迭代了:
for iter in epoch:
batch_content = sess.run(content_batch)
网友评论