Model lifecycle management

RZT aiOS, keeps tracks of all the ML and DL models trained. One can view the list of models trained along with details such as model name, model type (ML/DL), hyper parameters and metrics associated with the trained model

View all trained models

The api razor.api.trained_models() can be used to get the list of all models trained in the current project. The api, when called without any parameter, returns an instance of class razor.api.core.model.trained_model.TrainedModelMetaList which is a collection of razor.api.core.model.trained_model.TrainedModelMeta instances. TrainedModelMeta is a wrapper over model run details and allows user to access properties of a trained model as attributes

razor.api.trained_models()

Filtering and sorting

TrainedModelMetaList is a List wrapper over TrainedModelMeta objects and allows functionality like sort and filter on it.

Sorting trained model list

List of trained models can be sorted as per user's requirement by giving necessary sort key. For example, the following code lists all the trained models in descending order of number of epochs

from razor.api import trained_models
trained_models().sort(sort_key='hyper_params.EPOCHS', reverse=True)

Filtering

List of models can be filtered using model attributes. The function filter() takes an argument filter_func which is a function that will be evaluated for each trained model. A trained model is included in the returned list only if the filter_func evaluates True for that trained model. For example, the following code returns only the models which are trained for less than 5 epochs

from razor.api import trained_models
trained_models().filter(filter_func=lambda x: isinstance(x.hyper_params, dict) and
                        'epoch' in x.hyper_params.keys() and
                         x.hyper_params['epoch'] < 5)

Note: Both filter and sort return TrainedModelMetaList object and so can be cascaded

View properties of individual trained models

To get the details of a particular trained model, trained_models api can be called with parameter run_name

tm =razor.api.trained_models(run_name="Train_13")

This returns an instance of TrainedModelMeta class

tm =razor.api.trained_models(run_name="Train_13")

Trained Models

Param Value
Run NameTrain_13
Model Namemnist_classification
Trained On04:47:12, 2020-10-14
Trained ByJoe
DescriptionNone
Hyper Params
lr
adam1 0.001
epochs 10
batch_size 64
Train MetricsNA
Test MetricsNA
Valid MetricsNA
EnvironmentSDK
Model TypeDL
Save Nameimage_classification_s1
MLC Key
pipelineID fceae98e-0dd7-11eb-8fc2-0242ac110004
pipelineRunID b298ce50-f8d0-4662-9ee2-fbf34f60fbf1
blockID efcaaed5-c335-4bc8-a8cd-34e9e14ed96a
version None
pipelineName Image Classification Training Pipeline
blockName DLTrainBlock_1
pipelineRunName RUN - 57
saveName image_classification_s1
modelName mnist_classification

In order to retrieve a trained model based on the parameters passed, one can also use razor.api.core.mlc.MLC as shown in example below

from razor.api.core.mlc import MLC
keys={"model_name": "custom_model", "tag": "titanic"}

model = MLC().get(keys=keys,
          model_type="DL",
          model_name="custom_model",
          run_name="Train_12",
          save_name="custom_model_save",
          environment="SDK")