Skip to content

Instantly share code, notes, and snippets.

@guschmue
Created May 8, 2017 18:14
Show Gist options
  • Save guschmue/fef2018cefb327c45f7619e26f530837 to your computer and use it in GitHub Desktop.
Save guschmue/fef2018cefb327c45f7619e26f530837 to your computer and use it in GitHub Desktop.
simple_scalar_test.py
import os
import time
import tensorflow as tf
out_dir = os.path.abspath(os.path.join(os.path.curdir, "runs", str(int(time.time()))))
if not os.path.exists(out_dir):
os.mkdir(out_dir)
x = tf.placeholder(tf.float32, name="x")
init_op = tf.global_variables_initializer()
summary_op = tf.summary.scalar("steps", x)
with tf.Session() as sess:
sess.run(init_op)
summary_writer = tf.summary.FileWriter(out_dir, sess.graph)
for step in range(10):
summary = sess.run(summary_op, feed_dict={x: step})
summary_writer.add_summary(summary, step)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment