YZLITE Model

The YZLiteModel is the root object used to create a model specification.

The model specification should define an object that inherits YZLiteModel and any other required mixins. Once the object is defined and instantiated, the various properties should be populated. After the model specification is finished, it may be invoked with one of the various Model Operations.

Example Usage

The following is a snippet from the basic_example reference model:

import yzlite.core as yzlite_core

class MyModel(
    yzlite_core.YZLiteModel,    # We must inherit the YZLiteModel class
    yzlite_core.TrainMixin,   # We also inherit the TrainMixin since we want to train this model
    yzlite_core.DatasetMixin, # We also need the DatasetMixin mixin to provide the relevant dataset properties
    yzlite_core.EvaluateClassifierMixin,  # While not required, also inherit EvaluateClassifierMixin to help will generating evaluation for our classification model
):
    pass

my_model = MyModel()

my_model.version = 1
my_model.description = 'Basic model specification example'
my_model.classes = ['cat', 'dog', 'goat']
my_model.class_weights = 'balanced'
my_model.batch_size = 32
my_model.epochs = 100
my_model.validation_split = 0.2
...

if __name__ == '__main__':
    # Train the model
    # This does the same as issuing the command: yzlite train basic_example
    yzlite_core.train_model(my_model, clean=True)
    # Evaluate the model against the quantized .tflite (i.e. int8) model
    # This does the same as issuing the command: yzlite evaluate basic_example --tflite
    yzlite_core.evaluate_model(my_model, tflite=True)
    # Profile the model in the simulator
    # This does the same as issuing the command: yzlite profile basic_example
    yzlite_core.profile_model(my_model)

See the reference models for more examples.

Additional Model Utilities are also available.

API Reference

The following YZLiteModel mixins are available:

yzlite.core.YZLiteModel

The root YZLITE Model object

yzlite.core.TrainMixin

Provides training properties and methods to the base YZLiteModel

yzlite.core.DatasetMixin

Provides generic dataset properties to the base YZLiteModel

yzlite.core.AudioDatasetMixin

Provides audio dataset properties to the base YZLiteModel

yzlite.core.ImageDatasetMixin

Provides image dataset properties to the base YZLiteModel

yzlite.core.EvaluateMixin

Provides generic evaluation properties and methods to the base YZLiteModel

yzlite.core.EvaluateAutoEncoderMixin

Provides evaluation properties and methods to the base YZLiteModel

yzlite.core.EvaluateClassifierMixin

Provides evaluation properties and methods to the base YZLiteModel

yzlite.core.SshMixin

Provides various properties to the base YZLiteModel used by the ssh YZLITE command.

yzlite.core.WeightsAndBiasesMixin

Provides various properties to the base YZLiteModel used by Weights & Biases 3rd-party cloud backend.

yzlite.core.YZLiteDataset

Helper class for configuring a training dataset

yzlite.core.YZLiteModelEvent

Events that are triggered at various stages of YZLiteModel execution.