3

How can I read a tensorboard file programatically and see all scalar values (loss and metrics)? My question is related to this question on how to read data from tensorboard files.

Following @user1501961's approach and using tensorboard.backend.event_processing.event_accumulator.EventAccumulator, I could read the loss for training. However, I have not figured out the way to see the loss for evaluation. Since the loss for evaluation appears in tensorboard, the data should be somehow buried in the log directory.

Here is part of my script that reads training loss:

In [1]: from tensorboard.backend.event_processing import event_accumulator
In [2]: ea = event_accumulator.EventAccumulator('PATH_TO_LOGGING_DIR', size_guidance={event_accumulator.SCALARS:0});
In [3]: ea.Reload();
In [4]: ea.scalars.Keys()
Out[4]:
['enqueue_input/queue/enqueue_input/random_shuffle_queuefraction_over_250_of_750_full',
 'loss',
 'global_step/sec']
In [5]: ea.Scalars('loss') # only training loss is read.
Out[5]: 
[ScalarEvent(wall_time=1524534430.8867674, step=1, value=0.7076440453529358),
 ScalarEvent(wall_time=1524534523.8320634, step=101, value=0.6497592926025391),
 ScalarEvent(wall_time=1524534554.9782603, step=201, value=0.6366756558418274),
 ScalarEvent(wall_time=1524534586.3355439, step=301, value=0.504106879234314),
...

I use tf.estimator.train_and_evaluate() to save the loss and other metrics, if that matters.

Taro Kiritani
  • 724
  • 6
  • 24

1 Answers1

1

Silly me. I found a sub-folder called 'eval' in the logging directory. The EventAccumulator could parse the content the same way as for training data.

Taro Kiritani
  • 724
  • 6
  • 24