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
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()
TrainedModelMetaList
is a List wrapper over TrainedModelMeta objects and allows functionality like sort
and filter
on it.
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)
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
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")
Param | Value | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Run Name | Train_13 | ||||||||||||||||||
Model Name | mnist_classification | ||||||||||||||||||
Trained On | 04:47:12, 2020-10-14 | ||||||||||||||||||
Trained By | Joe | ||||||||||||||||||
Description | None | ||||||||||||||||||
Hyper Params |
| ||||||||||||||||||
Train Metrics | NA | ||||||||||||||||||
Test Metrics | NA | ||||||||||||||||||
Valid Metrics | NA | ||||||||||||||||||
Environment | SDK | ||||||||||||||||||
Model Type | DL | ||||||||||||||||||
Save Name | image_classification_s1 | ||||||||||||||||||
MLC Key |
|
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")