Skip to content

Logging to multiple objects at once#

To log to multiple runs or other Neptune objects in one script, you can initialize multiple objects.

You can then log metadata to each object separately.

Example#

In the following example, we create and log metadata to three separate runs.

import neptune

# Start 1st run
run1 = neptune.init_run(
    project="common/showroom",
    name="logging-to-multipe-runs",
    tags=["do-not-remove", "multiple"],
)
run1["params"] = {"lr": 0.007}

# Start 2nd run
run2 = neptune.init_run(
    project="common/showroom",
    name="logging-to-multipe-runs",
    tags=["do-not-remove", "multiple"],
)
run2["params"] = {"lr": 0.0034}

# Start 3rd run
run3 = neptune.init_run(
    project="common/showroom",
    name="logging-to-multipe-runs",
    tags=["do-not-remove", "multiple"],
)
run3["params"] = {"lr": 0.005}

# Log metric to run1
for j in range(1, 101):
    run1["train/loss"].append(0.7 / j**0.5)

# Log metric to run2
for j in range(1, 101):
    run2["train/loss"].append(0.8 / j**0.5)

# Log metric to run3
for j in range(1, 101):
    run3["train/loss"].append(0.9 / j**0.5)

# Stop tracking
run1.stop()
run2.stop()
run3.stop()