pythonメニュー

tensorboardコマンド

write_graph.py

# -*- coding: utf-8 -*-

import tensorflow as tf
import os

# TensorBoard情報出力ディレクトリ
log_dir = 'logstest'

logpath = os.getcwd() +'/' + log_dir

# 指定したディレクトリがあれば削除し、再作成
if tf.gfile.Exists(logpath):
    tf.gfile.DeleteRecursively(logpath)
tf.gfile.MakeDirs(logpath)
print( "["+logpath + "]に,情報が生成されます。")


def out_graph(z):
    sess = tf.InteractiveSession()
    # 
    summary_writer = tf.summary.FileWriter(logpath , sess.graph)
    # 実行
    print(sess.run(z))
    # SummaryWriterクローズ
    summary_writer.close()
    print("実行後、tensorboard --logdir=" + log_dir)

t_e_m_p = tf.constant(1, name="t_e_m_p") # 他の変数と同じにならないようにネーミング
out_graph(t_e_m_p)