利用tensorboard可视化cost

在cost后添加:

cost = tf.reduce_mean(tf.pow(X - y_pred, 2))  # 最小二乘法
tf.summary.scalar('cost', cost)

在sess.run(init)后添加:

with tf.Session() as sess:
    init = tf.initialize_all_variables()
    init = tf.global_variables_initializer()
    sess.run(init)
    merged = tf.summary.merge_all()
    writer = tf.summary.FileWriter('logs', sess.graph)

训练:

   _, result, c, encoder_, decoder_ = sess.run([optimizer, merged, cost, encoder_op, decoder_op], feed_dict={X: batch_xs})
 writer.add_summary(result, epoch*total_batch+i)

然后生成logs
cmd命令:G:\TensorFlow\TEST6>tensorboard --logdir=logs
生成链接:
在这里插入图片描述
复制链接,在Chrome中打开:
利用tensorboard可视化cost_第1张图片

你可能感兴趣的:(利用tensorboard可视化cost)