2016-12-28 15 views
7

Verileri giriş boru hattı yöntemleriyle grafiğe besliyorum ve toplu veri oluşturmak için tf.train.shuffle_batch uygulandı. Ancak, eğitim ilerledikçe, tensorflow daha sonraki iterasyonlar için yavaşlar ve yavaşlar. Buna neden olan temel neden hakkında kafam karıştı mı? Çok teşekkürler! Kod snippet'ım:Yineleme 10,000'den fazla olduğunda Tensorflow eğitimi yavaşlar ve yavaşlar. Niye ya?

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() 
+0

ama antrenman döngüde şey grafiğine düğümleri ekleyerek şüpheleniyorsanız: Böyle bir şey çalışıyorum tavsiye , bu yardımcı olur. Bu durumda, bir bellek sızıntısı da çekebilirsiniz, bu yüzden [bu belge] (http://stackoverflow.com/documentation/tensorflow/3883/how-to-debug-a-memory-leak-in- tensorflow/13426/use-graph-finalize-to-catch-düğümleri-eklenen-grafik-t # t = 201612280201558374055) olası bir hata ayıklama tekniğine sahiptir. – mrry

+0

Bir Shlemiel The Ressam algoritması gibi görünüyor. Başka bir yere meta veri ekleyerek onu O (n) ekleme süresine sahip bir veri yapısına ekleyerek/birleştirerek mi hesaplıyorsunuz? –

+0

Kod snippet'imi gönderdim, çok teşekkür ederim! – Lei

cevap

1

Eğitim sırasında sadece bir kez sess.run yapmalısınız. Bu programı görmeden söylemek zor

with tf.Session() as sess: 
    sess.run(tf.global_variables_initializer()) 
    for i in range(train_set_size * epoch): 
    train_step.run([optimizer, depth_loss, prediction]) 
İlgili konular