Creating model versions
How to track versions of a registered model
Once you have registered a model, you can create and store versions of it. This lets you track the stage, binaries, and relevant metadata of each model version separately.
Before you start:
  • To create a new model version, you need to have a model registered in a Neptune project. You can find your models under the Models tab.
To create and store a model version:
  1. 1.
    Import Neptune and initialize a Model version object:
1
import neptune.new as neptune
2
3
model_version = neptune.init_model_version(
4
model="MODEL_ID",
5
)
Copied!
where MODEL_ID is the Neptune id of the model. It is of the form: PROJECT_KEY-MODEL_KEY. For example, PROJ-MOD. It is stored in the sys/id field.
The model version id will have the form: PROJECT_KEY-MODEL_KEY-MODEL_VERSION_NUMBER.
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.
2. (optional) Upload the trained model weights as a binary file:
1
model_version["model/binary"].upload("model.pt")
Copied!
3. (optional) Log some model parameters and other metadata:
1
model_params = {
2
"eta": 0.3,
3
"gamma": 0.0001,
4
"max_depth": 2,
5
...
6
}
7
8
model_version["model/parameters"] = model_params
9
model_version["model/environment"].upload("environment.yml")
10
model_version["validation/dataset"].track_files("s3://datasets/validation")
11
model_version["validation/acc"] = 0.97
Copied!
4. To stop the connection to Neptune and sync all data, call the stop() method and execute the script or cell:
1
model_version.stop()
Copied!

What to do next

To view the created model version in Neptune, click the link in the console output. It looks like the following:
https://app.neptune.ai/.../v/PROJECT_KEY-MODEL_KEY-VERSION_NUMBER
Export as PDF
Copy link
Contents