Skip to content

Instantly share code, notes, and snippets.

@tudorjnu
Created May 19, 2023 12:44
Show Gist options
  • Save tudorjnu/730518856bc9a43c52635d2fa8e3f274 to your computer and use it in GitHub Desktop.
Save tudorjnu/730518856bc9a43c52635d2fa8e3f274 to your computer and use it in GitHub Desktop.
parses a tensorboard file
def parse_tensorboard_log(path: Path):
from tensorboard.backend.event_processing.event_accumulator import EventAccumulator
import pandas as pd
tag = 'rollout/ep_len_mean'
acc = EventAccumulator(path)
acc.Reload()
# check if the tag exists
if tag not in acc.Tags()['scalars']:
print("Tag not found")
return
df = pd.DataFrame(acc.Scalars(tag))
df = df.drop(columns=['wall_time']).groupby('step').mean()
return df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment