5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

tensorflowのscalar_summaryのログを展開する

Last updated at Posted at 2016-08-18

Tensorflow.SummaryWriterで書き出されるログファイルはtensorboardで開くことで中身を確認できる.しかし自分のプログラム内で自由に使いたい場合はログファイルを自前で扱えるような形で展開する必要がある.tensorboardではtensorflow.python.summary.event_accumulator.EventAccumulatorという関数を使っているようなので,これを流用すれば比較的簡単に取り出すことが可能.

parse_scalar.py
from tensorflow.python.summary.event_accumulator import EventAccumulator
import numpy as np

def scalar2arrays(scalarEvents):
    """
    converts scalarEvent to set of numpy.array
    """
    wall_times = []
    steps = []
    values = []

    for event in scalarEvents:
        wall_times.append(event.wall_time)
        steps.append(event.step)
        values.append(event.value)

    return np.array(wall_times), np.array(steps), np.array(values)

accumulator = EventAccumulator('filename-of-event-file')
accumulator.Reload() # load event files

wall_times, steps, values = scalar2arrays(accumulator.Scalars('name-of-summary'))

lossをmatplotlibでプロットし直すことができるようなった.

5
4
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
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?