Python 在tensorflow中预加载数据,性能差
我随后将整个数据集进行了预加载Python 在tensorflow中预加载数据,性能差,python,performance,tensorflow,profiling,Python,Performance,Tensorflow,Profiling,我随后将整个数据集进行了预加载 with tf.variable_scope("input"): X_train_tf = tf.constant(X_train, dtype=tf.float32) data_queue = tf.train.slice_input_producer([X_train_tf], capacity=4096, shuffle=True) data_batch = tf.train.batch(data_queue, batch_size=
with tf.variable_scope("input"):
X_train_tf = tf.constant(X_train, dtype=tf.float32)
data_queue = tf.train.slice_input_producer([X_train_tf], capacity=4096, shuffle=True)
data_batch = tf.train.batch(data_queue, batch_size=batch_size, capacity=4096)
...
create_model(data_batch)
...
sess.run(training_step)
其中X_列是一个形状的数组(3100,10,9,9),然后我使用数据批,就像我之前在图中使用的tf.占位符一样
这是可行的,但它实际上比我刚使用feed_dict时慢。我的GPU使用率约为40%,所以我猜这部分是瓶颈
输入生成器和批处理队列隐式地添加了一个摘要op,它告诉我批处理队列永远不会满。tf.train.batch中的摘要op“input/batch/fraction\u of_4096_full”经常报告0.0,但我不知道为什么
我正在使用tf.train.MonitoredTrainingSession,它应该处理启动队列运行程序和初始化所有变量
TLDR:为什么tf.constant+tf.train.slice\u input\u producer+tf.train.batch会导致批次的队列大部分为空