我正在尝试训练neural network
。一个训练循环需要几个小时才能完成。我必须运行此训练循环100次。我想测量每个训练循环的时间。 time.time()
函数可在几秒钟内给出。但我想用hours:minuts:sec
for i in range(30000):
batch = train.next_batch(FLAGS.batch_size)
optimizer.run(feed_dict={x:batch[0], y_: batch[1], keep_prob:0.5})
答案 0 :(得分:1)
import datetime
import time
for i in range(30000):
start = time.time()
batch = train.next_batch(FLAGS.batch_size)
optimizer.run(feed_dict={x:batch[0], y_: batch[1], keep_prob:0.5})
print('Training took {}'.format(datetime.timedelta(seconds = time.time()-start)))