Skip to content

Log parameters and model configuration#

You can define a namespace for storing any parameters or hyperparameters. Assign the values one by one, or define a dictionary of values.

In each of the below examples, the parameters are stored in a namespace called "parameters". Inside that namespace, a field is created for each parameter.

You'll find your logged parameters in the All metadata section of the run.

See example in Neptune 


You can display parameters in the runs table and custom dashboards.

Assigning parameters one by one#

run["parameters/epoch_nr"] = 5
run["parameters/batch_size"] = 32
run["parameters/dense"] = 512
run["parameters/optimizer"] = "sgd"
run["parameters/metrics"] = ["accuracy", "mae"]
run["parameters/activation"] = "ReLU"

Assigning parameters as dictionary#

You can assign a dictionary to a variable, then assign that to a run namespace:

With "="
params = {
    "epoch_nr": 5,
    "batch_size": 32,
    "dense": 512,
    "optimizer": "sgd",
    "metrics": ["accuracy", "binary_accuracy"],
    "activation": "ReLU",
run["parameters"] = params

You can also use the assign() method to pass a dictionary with the namespace name as the key and the dictionary of parameters as the value:

With assign()
        "parameters": {
            "epoch_nr": 5,
            "batch_size": 32,
            "dense": 512,
            "optimizer": "sgd",
            "metrics": ["accuracy", "binary_accuracy"],
            "activation": "ReLU",

Assigning parameters with argparse#

You can also assign arguments parsed with argparse to a namespace in the run.

import argparse

argparser = argparse.ArgumentParser()
argparser.add_argument("--lr", default=0.01)
argparser.add_argument("--batch", default=32)
argparser.add_argument("--activation", default="ReLU")

args = argparser.parse_args()
run["parameters"] = args