Created
November 15, 2022 13:11
-
-
Save KennethEnevoldsen/364161ca7af1ea892757682c2244a9b8 to your computer and use it in GitHub Desktop.
Log wandb metrics when run is finished.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Load in a wandb run and updates its run history with a new metric. | |
DOCS: https://docs.wandb.ai/guides/track/public-api-guide#update-config-for-an-existing-run | |
""" | |
import wandb | |
api = wandb.Api() | |
entity, project = "kenevoldsen", "mnist-test" # set to your entity and project | |
run_id = "q564eoml" # set to your run id | |
# to get all runs use api.runs(enti | |
# ty + "/" + project) | |
run = api.run(entity + "/" + project + "/" + run_id) | |
type(run.history()) | |
# pandas.core.frame.DataFrame | |
print(run.history()) | |
# _step loss _runtime _timestamp Accuracy | |
# 0 0 2.358063 0.870733 1.666799e+09 NaN | |
# 1 1 2.409657 0.913244 1.666799e+09 NaN | |
# 2 4 2.331224 0.925087 1.666799e+09 NaN | |
run.name # fetch the run name | |
# update run summary (not really want we want as we want to be able to plot the metrics over steps) | |
# however that is not possible with the public API yet (see: https://github.com/wandb/wandb/issues/2723) | |
run.summary.update({"Accuracy": 0.9}) | |
run = wandb.init(project=project, id=run_id, resume=True) | |
for i in range(10): | |
run.log({"epoch": i, "my_new_metric": 1.0}) | |
# note: you cannot use step here instead of epoch | |
run.finish() | |
# so for dfm it would be: | |
# run = wandb.init(project=project, id=run_id, resume=True) | |
# run.log({"train/global_step": step_for_scores, "scaneval_metric_1": score, ...}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment