Registering a model
How to register a model and track model metadata in Neptune
Once you have trained a model that you would like to save and version, you can register it in Neptune and track any kind of metadata associated with it.
The Model object is suitable for storing general metadata that is common to all versions of the model during the training process. For example, the model signature and validation datasets.
To create and store a model:
  1. 1.
    Import Neptune and initialize a Model object:
1
import neptune.new as neptune
2
3
model = neptune.init_model(
4
name="MODEL_NAME",
5
key="MODEL_KEY",
6
)
Copied!
where
  • MODEL_NAME is the name of your model. For example, Prediction model.
  • MODEL_KEY is the key of your model. For example, MOD. The key must be uppercase and unique within the project.
The model id will have the form: PROJECT_KEY-MODEL_KEY. It is stored in the sys/id field.
If you have not saved your project name and Neptune API token as environment variables, pass them through the project and api_token arguments. For instructions, see Installation and setup.
To see the model in Neptune, navigate to the Models tab. You can now begin tracking specific versions of the model you've created.
2. (optional) You can also store any metadata you want:
Track model metadata by assigning them to the model object:
1
model_info = {"size_limit": 50.0, "size_units": "MB"}
2
model["model"] = model_info
Copied!
Upload the model signature and other data with the upload() method:
1
model["model/signature"].upload("model_signature.json")
Copied!
Track dataset versions with the track_files() method:
1
model["data/train"].track_files("data/train.csv")
2
model["data/validation/dataset/v0.1"].track_files("s3://datasets/validation")
Copied!
3. To stop the connection to Neptune and sync all data, call the stop() method and execute the script or cell:
1
model.stop()
Copied!

What to do next

To go directly to the created model in Neptune, click the link in the console output. It looks like the following:
https://app.neptune.ai/WORKSPACE_NAME/PROJECT_NAME/m/PROJECT_KEY-MODEL_KEY
Export as PDF
Copy link
Contents