-
Notifications
You must be signed in to change notification settings - Fork 38
DVC magic
Paweł Redzyński edited this page Jan 4, 2021
·
6 revisions
Usually in loggers one need to "initialize" the logger/experiment, in order to save the logs.
With dvc
and dvclive
user can go straight to logging.
train.py
:
import dvclive
import time
def get_params():
from ruamel.yaml import YAML
yaml = YAML(typ="safe")
params_path = "params.yaml"
with open(params_path, "r") as fd:
return yaml.load(fd)
def metric(i):
p = float(get_params()["power"])
return 1 - 1/(1+i**p)
def loss(i):
return 1-(metric(i))
if __name__ == "__main__":
for i in range(100):
dvclive.log("metric", metric(i))
dvclive.log("loss", loss(i))
Note that we are not calling init
, nor next_epoch
Install dvc from dvclive
branch on main repo.
- Copy
train.py
echo "power: 0.2" > params.yaml
- git init --quiet && dvc init --quiet
- git add -A && git commit -m "initial"
dvc run -n train --params power -d train.py --live training_logs python train.py
- git add -A && git commit -am "baseline"
-
echo "power: 0.4" > params.yaml
&&dvc repro train
dvc plots diff
We end up having training_logs
inside our repo.