'''
Created on May 24, 2017
@author: p0079482
'''
#使用程序输出日志
import tensorflow as tf
with tf.Session() as sess:
tf.initialize_all_variables().run()
for i in range(TRAINING_STEPS):
xs,ys=mnist.train.next_batch(BATCH_SIZE)
#每1000轮记录一次运行状态
if i%1000==0:
#配置运行时需要记录的信息
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
#运行时记录运行信息的proto
run_metadata=tf.RunMetadata()
#将配置信息和记录运行信息的proto传入运行的过程,从而记录运行时每一个节点的时间、空间开销信息
_,loss_value,step=sess.run([train_op,loss,global_step],
feed_dict={x:xs,y_:ys},
options=run_options,run_metadata=run_metadata)
#将节点在运行时的信息写入日志文件
train_writer.add_run_metadata(run_metadata,'step%03d'%i)
print("After %d training step(s),loss on training batch is %g."%(step,loss_value))
else:
_,loss_value,step=sess.run([train_op,loss,global_step],feed_dict={x:xs,y_:ys})
Created on May 24, 2017
@author: p0079482
'''
#使用程序输出日志
import tensorflow as tf
with tf.Session() as sess:
tf.initialize_all_variables().run()
for i in range(TRAINING_STEPS):
xs,ys=mnist.train.next_batch(BATCH_SIZE)
#每1000轮记录一次运行状态
if i%1000==0:
#配置运行时需要记录的信息
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
#运行时记录运行信息的proto
run_metadata=tf.RunMetadata()
#将配置信息和记录运行信息的proto传入运行的过程,从而记录运行时每一个节点的时间、空间开销信息
_,loss_value,step=sess.run([train_op,loss,global_step],
feed_dict={x:xs,y_:ys},
options=run_options,run_metadata=run_metadata)
#将节点在运行时的信息写入日志文件
train_writer.add_run_metadata(run_metadata,'step%03d'%i)
print("After %d training step(s),loss on training batch is %g."%(step,loss_value))
else:
_,loss_value,step=sess.run([train_op,loss,global_step],feed_dict={x:xs,y_:ys})