LoginSignup
0
0

More than 3 years have passed since last update.

KerasなしでTensorBoardを使う

Posted at

現状

けど、環境が違うのであんまり参考にならなかった。
ということで行き詰っていたんだけど進捗があったので投稿

docにexampleがあってわかりやすかった

tf.summary.__doc__

で出てきた例が自分の参考にしたコードに近くて役に立った

writer = tf.summary.create_file_writer("/tmp/mylogs")

@tf.function
def my_func(step):
  # other model code would go here
  with writer.as_default():
    tf.summary.scalar("my_metric", 0.5, step=step)

for step in range(100):
  my_func(step)
  writer.flush()

0.5のところをモニターしたい値に変えればOK

tf.summary.scalar("loss", loss, step=step)
"""
(名前,縦軸の値,横軸の値)
"""

マジックコマンドも加えると


writer = tf.summary.create_file_writer("/log")

@tf.function
def my_func(step):
  # other model code would go here
  with writer.as_default():
    tf.summary.scalar("loss", loss, step=step)


%tensorboard --logdir=/logs
for step in range(100):
  my_func(step)
  writer.flush()

所感

記事には書いてないけど、ログファイルの場所や書き方がいろいろあったのが一番詰まっていたところかもしれない
kerasで楽々tensorboardしたかった( ˘ω˘ )
もっといい方法あったら教えてください。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0