2017-11-25 1 views
0

In Tensor Flow 1.4, die tf.data.Dataset Klasse bietet eine repeat() -Funktion, um Epochen zu machen, aber seine Leistung wird langsamer und langsamer mit der Zunahme der Epochen ! Hiertensorflow Dataset konsumierende Daten werden langsamer mit der Zunahme der Epochen

ist der Code:

num_data = 1000 
num_epoch = 50 
batch_size = 32 
dataset = tf.data.Dataset.range(num_data) 
dataset = dataset.repeat(num_epoch).batch(batch_size) 
iterator = dataset.make_one_shot_iterator() 

with tf.Session() as sess: 
    for epoch in xrange(num_epoch): 
     t1 = time.time() 
     for i in xrange(num_data/batch_size): 
      a = sess.run(iterator.get_next()) 
     t2 = time.time() 
     print 'epoch %d comsuming_time %.4f'%(epoch,t2-t1) 

und seine Ausgänge:

epoch 0 comsuming_time 0.1604 
epoch 1 comsuming_time 0.1725 
epoch 2 comsuming_time 0.1839 
epoch 3 comsuming_time 0.1942 
epoch 4 comsuming_time 0.2213 
epoch 5 comsuming_time 0.2430 
epoch 6 comsuming_time 0.2361 
epoch 7 comsuming_time 0.2512 
epoch 8 comsuming_time 0.2607 
epoch 9 comsuming_time 0.2936 
epoch 10 comsuming_time 0.3282 
epoch 11 comsuming_time 0.2990 
epoch 12 comsuming_time 0.3105 
epoch 13 comsuming_time 0.3239 
epoch 14 comsuming_time 0.3393 
epoch 15 comsuming_time 0.3518 
epoch 16 comsuming_time 0.3673 
epoch 17 comsuming_time 0.3859 
epoch 18 comsuming_time 0.3928 
epoch 19 comsuming_time 0.4090 
epoch 20 comsuming_time 0.4206 
epoch 21 comsuming_time 0.4333 
epoch 22 comsuming_time 0.4479 
epoch 23 comsuming_time 0.4631 
epoch 24 comsuming_time 0.4774 
epoch 25 comsuming_time 0.4923 
epoch 26 comsuming_time 0.5533 
epoch 27 comsuming_time 0.5187 
epoch 28 comsuming_time 0.5319 
epoch 29 comsuming_time 0.5470 
epoch 30 comsuming_time 0.5647 
epoch 31 comsuming_time 0.5796 
epoch 32 comsuming_time 0.6036 

Antwort

0

Ich glaube, ich habe das Problem gefunden. Es ist sess.run (iterator.get_next()). Das Predifining von get_next_op = iterator.get_next() außerhalb der Schleife und das Ausführen von sess.run (get_next_op) ist in Ordnung.

Verwandte Themen