-
Notifications
You must be signed in to change notification settings - Fork 1
/
dashboard.py
41 lines (32 loc) · 1.24 KB
/
dashboard.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import os
from pathlib import Path
from comet_ml import Experiment, ExistingExperiment
class Dashboard:
"""Record training/evaluation statistics to comet
"""
def __init__(self, args, workspace: str, api_key: str):
self.experiment = Experiment(api_key=api_key,
project_name="Sequential-ddtr",
workspace=workspace)
self.experiment.log_parameters(vars(args))
self.epochs = 1
self.global_step = 1
self.status = "evaluating"
def set_status(self, status: str):
## training/ evaluating
assert status == "training" or status == "evaluating"
self.status = status
def step(self):
self.global_step += 1
def update_epoch(self):
self.epochs += 1
def log_metrics(self, metrics: dict):
if self.status == "training":
with self.experiment.train():
self.experiment.log_metrics(metrics, step=self.global_step)
else:
with self.experiment.validate():
self.experiment.log_metrics(metrics, step=self.epochs)
def check(self):
if not self.experiment.alive:
print("Comet logging stopped")