Last active
March 5, 2017 16:10
-
-
Save travishsu/c6c82dea591d5aae6f1def1bfc55d4c5 to your computer and use it in GitHub Desktop.
用 TensorBoard 的好處就是不用在寫 printout 惹~
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = tf.placeholder(.....) | |
# Scope: 運算區塊 | |
with tf.name_scope("operation_scope"): | |
weight = ... | |
l1 = op(x, w) | |
... | |
... | |
tf.summary.histogram("weight", weight) # 可以看 weight 值的分佈,只是我還不清楚分佈是指什麼 | |
# Cost | |
with tf.name_scope("cost"): | |
loss = ..... | |
tf.summary.scalar("loss", loss) # 把 loss 的值存起來 | |
# Training | |
with tf.name_scope("train"): | |
train = tf.train.SGD(0.01).minimize(loss) | |
init = tf.global_variables_initializer() | |
sess = tf.Session() | |
sess.run(init) | |
file_writer = tf.summary.FileWriter('/path/to/log_dir', sess.graph) | |
merged = tf.summary.merge_all() | |
# Iteration: save a group of values each iteration | |
for _ in range(max_iter): | |
fd = ... | |
summary, __ = sess.run([merged, train], feed_dict = fd) | |
file_writer.add_summary(summary, _) | |
# 在跑的時候,或跑完之後,只要 /path/to/log_dir 裡面有檔案,就可以在終端機下: | |
# tensorboard --logdir=/path/to/log_dir | |
# 然後用瀏覽器開它顯示的網址就有介面了,通常是 http://localhost:6006 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment