Create an experiment
To create a new experiment, use the Run()
constructor.
For example, to create a run that becomes the head of the seabird-flying-skills
experiment, use:
from neptune_scale import Run
run = Run(
run_id="astute-kittiwake-23",
experiment_name="seabird-flying-skills",
)
The above arguments are mandatory. The custom run ID provided to the
run_id
argument must be unique within the project.
Then, to track experiment metadata, call a logging method on the Run
object:
for step in epoch:
# your training loop
acc = ...
loss = ...
run.log_metrics(
data={"metrics/accuracy": acc, "metrics/loss": loss},
step=1,
)
By default, Neptune periodically synchronizes the data with the servers in the background. The connection to Neptune remains open until the run is stopped or the script finishes executing.
Passing run object between scripts
Once you've created a run with the Run()
constructor, you can pass it around multiple Python functions.
You can use the Run
object to populate parameters of functions imported from other files. This way, you can work with a larger codebase and log from multiple Python scripts at once.
Example
# Import from "utils.py" file
from utils import log_scores_epoch
run = Run(...)
# Log metrics in the same file
for step in epoch:
run.log_metrics(...)
# Log by using an imported function, passing "run" as the argument
log_scores_epoch(run=run)
def log_scores_epoch(run): # "run" is the Neptune run
score1 = ...
score2 = ...
run.log_configs(
{
"scores/score1": score1,
"scores/score1": score2,
},
)
Creating non-experiment runs
Forking and history is only supported for experiment runs.
To take advantage of these and other features that concern analysis of multiple related runs, create experiments rather than stand-alone runs.
It's possible to create stand-alone runs that aren't part of any experiment. In this case, only a unique run ID is required when creating the run:
run = Run(run_id="astute-kittiwake-178")
To display stand-alone runs in the web app, in the All runs tab, ensure that the toggle to show only experiment runs is disabled:
You can save your table configuration as a custom view, which makes it easier to work on the runs later.