How to access Neptune parameters from code?

Problem

I specified parameters in the parameters section of the neptune.yaml config file. How can I access those parameters programatically?

Solution

Lets assume that you specified parameters in the parameters section of the neptune.yaml

1
2
3
4
5
...
parameters:
   lr: 0.01
   nr_epochs: 10
   dropout: 0.2

Step 1

Create Neptune context

1
2
3
import neptune

ctx = neptune.Context()

Step 2

Use ctx.params attribute. It is an Attrdict object, so you can either treat it as a standard Python dictionary, or access its attributes with a familiar dot.

1
2
lr = ctx.params.lr
epochs = ctx.params['nr_epochs']

See also