Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TensorFlow - Importing data from a TensorBoard TFEvent file?

I've run several training sessions with different graphs in TensorFlow. The summaries I set up show interesting results in the training and validation. Now, I'd like to take the data I've saved in the summary logs and perform some statistical analysis and in general plot and look at the summary data in different ways. Is there any existing way to easily access this data?

More specifically, is there any built in way to read a TFEvent record back into Python?

If there is no simple way to do this, TensorFlow states that all its file formats are protobuf files. From my understanding of protobufs (which is limited), I think I'd be able to extract this data if I have the TFEvent protocol specification. Is there an easy way to get ahold of this? Thank you much.

like image 637
golmschenk Avatar asked May 18 '16 15:05

golmschenk


People also ask

How do I download data from TensorBoard?

Just check the "Data download links" option on the upper-left in TensorBoard, and then click on the "CSV" button that will appear under your scalar summary.

Can I use TensorBoard without TensorFlow?

Note: Having TensorFlow installed is not a prerequisite to running TensorBoard, although it is a product of the TensorFlow ecosystem, TensorBoard by itself can be used with PyTorch.


2 Answers

As Fabrizio says, TensorBoard is a great tool for visualizing the contents of your summary logs. However, if you want to perform a custom analysis, you can use tf.train.summary_iterator() function to loop over all of the tf.Event and tf.Summary protocol buffers in the log:

for summary in tf.train.summary_iterator("/path/to/log/file"):     # Perform custom processing in here. 

UPDATE for tf2:

from tensorflow.python.summary.summary_iterator import summary_iterator 

You need to import it, that module level is not currently imported by default. On 2.0.0-rc2

like image 139
mrry Avatar answered Sep 21 '22 21:09

mrry


To read a TFEvent you can get a Python iterator that yields Event protocol buffers.

# This example supposes that the events file contains summaries with a # summary value tag 'loss'.  These could have been added by calling # `add_summary()`, passing the output of a scalar summary op created with # with: `tf.scalar_summary(['loss'], loss_tensor)`. for e in tf.train.summary_iterator(path_to_events_file):     for v in e.summary.value:         if v.tag == 'loss' or v.tag == 'accuracy':             print(v.simple_value) 

more info: summary_iterator

like image 35
Temak Avatar answered Sep 21 '22 21:09

Temak