7
我使用輸入管道方法將數據輸入到圖中,並且實現了tf.train.shuffle_batch
以生成批處理數據。然而,隨着訓練的進行,對於以後的迭代,張量流變得越來越慢。我很困惑導致它的根本原因是什麼?非常感謝!我的代碼片段是:當迭代超過10,000時,Tensorflow訓練變得越來越慢。爲什麼?
def main(argv=None):
# define network parameters
# weights
# bias
# define graph
# graph network
# define loss and optimization method
# data = inputpipeline('*')
# loss
# optimizer
# Initializaing the variables
init = tf.initialize_all_variables()
# 'Saver' op to save and restore all the variables
saver = tf.train.Saver()
# Running session
print "Starting session... "
with tf.Session() as sess:
# initialize the variables
sess.run(init)
# initialize the queue threads to start to shovel data
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
print "from the train set:"
for i in range(train_set_size * epoch):
_, d, pre = sess.run([optimizer, depth_loss, prediction])
print "Training Finished!"
# Save the variables to disk.
save_path = saver.save(sess, model_path)
print("Model saved in file: %s" % save_path)
# stop our queue threads and properly close the session
coord.request_stop()
coord.join(threads)
sess.close()
很難沒有看到你的程序的說法,但我懷疑的東西在你的訓練環路節點添加到圖表。如果是這樣的話,你可能也會遭受內存泄漏,所以[本文檔](http://stackoverflow.com/documentation/tensorflow/3883/how-to-debug-a-memory-leak-in- tensorflow/13426/use-graph-finalize-to-catch-nodes-being-added-to-the-graph#t = 201612280201558374055)具有潛在的調試技術。 – mrry
聽起來像Shlemiel The Painter算法。你是否需要追蹤別的元數據?通過追加/連接它到O(n)插入時間的數據結構? –
我有我的代碼片段,非常感謝你! – Lei