Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tensorboard: Export CSV file from command line

Could someone please tell me whether Tensorboard supports exporting CSV files from the command line? The reason why I ask this is because I have a lots of logging directory and I am hoping to have a script file that automates the process. Thanks.

like image 230
Bojian Zheng Avatar asked Apr 06 '18 16:04

Bojian Zheng


People also ask

How do I download a CSV file 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. Save this answer. Show activity on this post.

How to download TensorBoard logs?

TensorBoard provides two types of data log for download . csv and . json . If you click run to download , then the download links for each data type are activated and you can download data.


1 Answers

The API supports reading files programmatically. Here's an example of extracting data for a tag and saving it to a .csv in a similar format to those generated by tensorboard

import argparse
import numpy as np
import tensorflow as tf

def save_tag_to_csv(fn, tag='test_metric', output_fn=None):
    if output_fn is None:
        output_fn = '{}.csv'.format(tag.replace('/', '_'))
    print("Will save to {}".format(output_fn))

    sess = tf.InteractiveSession()

    wall_step_values = []
    with sess.as_default():
        for e in tf.train.summary_iterator(fn):
            for v in e.summary.value:
                if v.tag == tag:
                    wall_step_values.append((e.wall_time, e.step, v.simple_value))
    np.savetxt(output_fn, wall_step_values, delimiter=',', fmt='%10.5f')

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('fn')
    parser.add_argument('--tag', default='test_metric')
    args = parser.parse_args()
    save_tag_to_csv(args.fn, tag=args.tag)
like image 83
eqzx Avatar answered Oct 16 '22 04:10

eqzx