Sacred integration API reference
API reference for the NeptuneObserver class of the Neptune-Sacred integration.
The Neptune-Sacred integration provides a Sacred observer that logs experiment metadata to Neptune.
NeptuneObserver
Logs Sacred experiment data to Neptune.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| run | RunorHandler | - | An existing run reference, as returned byneptune.init_run(), or anamespace handler. |
| base_namespace | str, optional | "experiment" | Namespace under which all metadata logged by the observer will be stored. |
Examples
Start a Neptune run:
import neptune
run = neptune.init_run()
As a best practice, you should save your Neptune API token and project name as environment variables:
export NEPTUNE_API_TOKEN="h0dHBzOi8aHR0cHM6Lkc78ghs74kl0jv...Yh3Kb8"
export NEPTUNE_PROJECT="ml-team/classification"
Alternatively, you can pass the information when using a function that takesapi_tokenandprojectas arguments:
run = neptune.init_run(
api_token="h0dHBzOi8aHR0cHM6Lkc78ghs74kl0jv...Yh3Kb8", # (1)!
project="ml-team/classification", # (2)!
)
- In the bottom-left corner, expand the user menu and select Get my API token .
- You can copy the path from the project details ( → Details & privacy ).
If you haven't registered, you can log anonymously to a public project:
api_token=neptune.ANONYMOUS_API_TOKEN
project="common/quickstarts"
Make sure not to publish sensitive data through your code!
Create an experiment:
from sacred import Experiment
ex = Experiment("image_classification", interactive=True)
Add a Neptune observer:
from neptune.integrations.sacred import NeptuneObserver
ex.observers.append(NeptuneObserver(run=run))
Define the model and run the experiment:
class BaseModel(torch.nn.Module):
...
model = BaseModel()
@ex.config
def cfg():
...
@ex.main
def _run(...):
...
ex.run()
See also
neptune-sacred repo onGitHub
This page is originally sourced from the legacy docs.