• Stars
    star
    162
  • Rank 232,284 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Aggregate multiple tensorboard runs to new summary or csv files

tensorboard-aggregator

This project contains an easy to use method to aggregate multiple tensorboard runs. The max, min, mean, median, standard deviation and variance of the scalars from multiple runs is saved either as new tensorboard summary or as .csv table.

There is a similar tool which uses pytorch to output the tensorboard summary: TensorBoard Reducer

Feature Overview

  • Aggregates scalars of multiple tensorboard files
  • Saves aggregates as new tensorboard summary or as .csv
  • Aggregate by any numpy function (default: max, min, mean, median, std, var)
  • Allows any number of subpath structures
  • Keeps step numbering
  • Saves wall time average per step

Setup and run configuration

  1. Download or clone repository files to your computer
  2. Go into repository folder
  3. Install requirements: pip3 install -r requirements.txt --upgrade
  4. You can now run the aggregation with: python aggregator.py

Parameters

Parameter Default Description
--path optional current working directory Path to folder containing runs
--subpaths optional ['.'] List of all subpaths
--output optional summary Possible values: summary, csv

Recommendation

  • Add the repository folder to the PATH (global environment variables).
  • Create an additional script file within the repository folder containing python static/path/to/aggregator.py
    • Script name: aggregate.sh / aggregate.bat / ... (depending on your OS)
    • Change default behavior via parameters
    • Do not change path parameter since this will by default be the path the script is run from
  • Workflow from here: Open folder with tensorboard files and call the script: aggregate files will be created for the current directory

Explanation

Example folder structure:

.
β”œβ”€β”€ ...
β”œβ”€β”€ test_param_xy      # Folder containing the runs for aggregation
β”‚   β”œβ”€β”€ run_1          # Folder containing tensorboard files of one run
β”‚   β”‚   β”œβ”€β”€ test       # Subpath containing one tensorboard file
β”‚   β”‚   β”‚   └── events.out.tfevents. ...
β”‚   β”‚   └── train   
β”‚   β”‚       └── events.out.tfevents. ...
β”‚   β”œβ”€β”€ run_2
β”‚   β”œβ”€β”€ ...
β”‚   └── run_X
└── ...

The folder test_param_xy will be the base path (cd test_param_xy). The tensorboard summaries for the aggregation will be created by calling the aggregate script (containing: python static/path/to/aggregator.py --subpaths ['test', 'train'] --output summary)

The base folder contains multiple subfolders. Each subfolder contains the tensorboard files of different runs for the same model and configuration as all other subfolders.

The resulting folder structure for summary looks like this:

.
β”œβ”€β”€ ...
β”œβ”€β”€ test_param_xy
β”‚   β”œβ”€β”€ ...
β”‚   └── aggregate
β”‚       β”œβ”€β”€ test
β”‚       β”‚   β”œβ”€β”€ max
β”‚       β”‚   β”‚   └── test_param_xy 
β”‚       β”‚   β”‚       └── events.out.tfevents. ...
β”‚       β”‚   β”œβ”€β”€ min
β”‚       β”‚   β”œβ”€β”€ mean
β”‚       β”‚   β”œβ”€β”€ median
β”‚       β”‚   └── std    
β”‚       └── train
└── ...

Multiple aggregate summaries can be put together in one directory. Since the original base folder name is kept as subfolder to the aggregate function folder the summaries are distinguishable within tensorboard.

.
β”œβ”€β”€ ...
β”œβ”€β”€ max
β”‚   β”œβ”€β”€ test_param_x
β”‚   β”œβ”€β”€ test_param_y
β”‚   β”œβ”€β”€ test_param_z
β”‚   └── test_param_v 
β”œβ”€β”€ min
β”œβ”€β”€ mean
β”œβ”€β”€ median
└── std   

The .csv table files for the aggregation will be created by calling the aggregate script (containing: python static/path/to/aggregator.py --subpaths ['test', 'train'] --output csv)

The resulting folder structure for summary looks like this:

.
β”œβ”€β”€ ...
β”œβ”€β”€ test_param_xy
β”‚   β”œβ”€β”€ ...
β”‚   └── aggregate
β”‚       β”œβ”€β”€ test
β”‚       β”‚   β”œβ”€β”€ max_test_param_xy.csv
β”‚       β”‚   β”œβ”€β”€ min_test_param_xy.csv
β”‚       β”‚   β”œβ”€β”€ mean_test_param_xy.csv
β”‚       β”‚   β”œβ”€β”€ median_test_param_xy.csv
β”‚       β”‚   └── std_test_param_xy.csv
β”‚       └── train
└── ...

The .csv files are primarily for latex plots.

Limitations

  • The aggregation only works for scalars and not for other types like histograms
  • All runs for one aggregation need the exact same tags. Basically the naming and number of scalar metrics needs to be equal for all runs.
  • All runs for one aggregation need the same steps. Basically the number of iterations, epochs and the saving frequency needs to be equal for all runs of one scalar.

Contributions

If there are potential problems (bugs, incompatibilities to newer library versions or to a OS) or feature requests, please create an GitHub issue here.

License

MIT License