mltk.core.MltkModelEvent

class MltkModelEvent[source]

Events that are triggered at various stages of MltkModel execution.

See add_event_handler for more details.

Properties

BEFORE_MODEL_LOAD

Invoked before the MltkModel is fully loaded.

AFTER_MODEL_LOAD

Invoked after the MltkModel is fully loaded.

BEFORE_LOAD_DATASET

Invoked at the beginning of load_dataset

AFTER_LOAD_DATASET

Invoked at the end of load_dataset

BEFORE_UNLOAD_DATASET

Invoked at the beginning of unload_dataset

AFTER_UNLOAD_DATASET

Invoked at the end of unload_dataset

SUMMARIZE_DATASET

Invoked at the end of summarize_dataset

SUMMARIZE_MODEL

Invoked at the end of summarize_model

TRAIN_STARTUP

Invoked at the beginning of train_model

BEFORE_BUILD_TRAIN_MODEL

Invoked before build_model_function is called

AFTER_BUILD_TRAIN_MODEL

Invoked after build_model_function is called

POPULATE_TRAIN_CALLBACKS

Invoked during train_model before Keras training starts.

BEFORE_TRAIN

Invoked during train_model before Keras training

AFTER_TRAIN

Invoked during train_model after Keras training

BEFORE_SAVE_TRAIN_MODEL

Invoked during train_model before the trained model is saved

AFTER_SAVE_TRAIN_MODEL

Invoked during train_model after the trained model is saved

BEFORE_SAVE_TRAIN_RESULTS

Invoked during train_model before the training results are saved

AFTER_SAVE_TRAIN_RESULTS

Invoked during train_model after the training results are saved

BEFORE_SAVE_TRAIN_ARCHIVE

Invoked during train_model before the model archive is saved

AFTER_SAVE_TRAIN_ARCHIVE

Invoked during train_model after the model archive is saved

TRAIN_SHUTDOWN

Invoked at the end of train_model

QUANTIZE_STARTUP

Invoked at the beginning of quantize_model

BEFORE_QUANTIZE

//www.tensorflow.org/lite/convert>`_ is invoked

AFTER_QUANTIZE

Invoked during quantize_model after the TfliteConverter is invoked

QUANTIZE_SHUTDOWN

Invoked at the end of quantize_model

EVALUATE_STARTUP

Invoked at the beginning of evaluate_model

EVALUATE_SHUTDOWN

Invoked at the end of evaluate_model

GENERATE_EVALUATE_PLOT

Invoked when generating a plot during evaluate_model

AFTER_PROFILE

Invoked at the end of profile_model

BEFORE_MODEL_LOAD = 'BEFORE_MODEL_LOAD'

Invoked before the MltkModel is fully loaded.

This event does not have any additional keyword arguments.

AFTER_MODEL_LOAD = 'AFTER_MODEL_LOAD'

Invoked after the MltkModel is fully loaded.

This event does not have any additional keyword arguments.

BEFORE_LOAD_DATASET = 'BEFORE_LOAD_DATASET'

Invoked at the beginning of load_dataset

This has the additional keyword arguments:

  • subset - One of training, validation or evaluation

  • test - True if the data is being loaded for testing

AFTER_LOAD_DATASET = 'AFTER_LOAD_DATASET'

Invoked at the end of load_dataset

This has the additional keyword arguments:

  • subset - One of training, validation or evaluation

  • test - True if the data is being loaded for testing

BEFORE_UNLOAD_DATASET = 'BEFORE_UNLOAD_DATASET'

Invoked at the beginning of unload_dataset

This event does not have any additional keyword arguments.

AFTER_UNLOAD_DATASET = 'AFTER_UNLOAD_DATASET'

Invoked at the end of unload_dataset

This event does not have any additional keyword arguments.

SUMMARIZE_DATASET = 'SUMMARIZE_DATASET'

Invoked at the end of summarize_dataset

This has the additional keyword arguments:

  • summary - The generated summary as a string, the summary cannot be modified in the event handler

  • summary_dict - The generated summary as summary_dict=dict(value=summary), summary_dict['value'] may be modified in the event handler

SUMMARIZE_MODEL = 'SUMMARIZE_MODEL'

Invoked at the end of summarize_model

This has the additional keyword arguments:

  • summary - The generated summary as a string, the summary cannot be modified in the event handler

  • summary_dict - The generated summary as summary_dict=dict(value=summary), Update summary_dict['value'] to return a new summary by the event handler

TRAIN_STARTUP = 'TRAIN_STARTUP'

Invoked at the beginning of train_model

This has the additional keyword arguments:

  • post_process - True if post-processing is enabled

BEFORE_BUILD_TRAIN_MODEL = 'BEFORE_BUILD_TRAIN_MODEL'

Invoked before build_model_function is called

This event does not have any additional keyword arguments.

AFTER_BUILD_TRAIN_MODEL = 'AFTER_BUILD_TRAIN_MODEL'

Invoked after build_model_function is called

This has the additional keyword arguments:

  • keras_model - The built Keras model

POPULATE_TRAIN_CALLBACKS = 'POPULATE_TRAIN_CALLBACKS'

Invoked during train_model before Keras training starts.

This has the additional keyword arguments:

  • keras_callbacks - A list of Keras Callbacks that will be passed to KerasModel.fit()

BEFORE_TRAIN = 'BEFORE_TRAIN'

Invoked during train_model before Keras training

This has the additional keyword arguments:

AFTER_TRAIN = 'AFTER_TRAIN'

Invoked during train_model after Keras training

This has the additional keyword arguments:

BEFORE_SAVE_TRAIN_MODEL = 'BEFORE_SAVE_TRAIN_MODEL'

Invoked during train_model before the trained model is saved

This has the additional keyword arguments:

  • keras_model - The trained Keras model, this cannot be modified by the event handler

  • keras_model_dict - The trained Keras model as keras_model_dict=dict(value=keas_model), update keras_model_dict['value'] to return a new model by the event handler

AFTER_SAVE_TRAIN_MODEL = 'AFTER_SAVE_TRAIN_MODEL'

Invoked during train_model after the trained model is saved

This has the additional keyword arguments:

  • keras_model - The trained Keras model, this cannot be modified by the event handler

  • keras_model_dict - The trained Keras model as keras_model_dict=dict(value=keas_model), update keras_model_dict['value'] to return a new model by the event handler

BEFORE_SAVE_TRAIN_RESULTS = 'BEFORE_SAVE_TRAIN_RESULTS'

Invoked during train_model before the training results are saved

This has the additional keyword arguments:

  • keras_model - The trained Keras model, this cannot be modified by the event handler

  • results - The model TrainingResults

  • output_dir - Directory path where the results are saved

AFTER_SAVE_TRAIN_RESULTS = 'AFTER_SAVE_TRAIN_RESULTS'

Invoked during train_model after the training results are saved

This has the additional keyword arguments:

  • keras_model - The trained Keras model, this cannot be modified by the event handler

  • results - The model TrainingResults

  • output_dir - Directory path where the results are saved

BEFORE_SAVE_TRAIN_ARCHIVE = 'BEFORE_SAVE_TRAIN_ARCHIVE'

Invoked during train_model before the model archive is saved

This has the additional keyword arguments:

  • archive_path - Path where archive will be saved

AFTER_SAVE_TRAIN_ARCHIVE = 'AFTER_SAVE_TRAIN_ARCHIVE'

Invoked during train_model after the model archive is saved

This has the additional keyword arguments:

  • archive_path - Path where archive was saved

TRAIN_SHUTDOWN = 'TRAIN_SHUTDOWN'

Invoked at the end of train_model

This has the additional keyword arguments:

  • results - The model TrainingResults

QUANTIZE_STARTUP = 'QUANTIZE_STARTUP'

Invoked at the beginning of quantize_model

This has the additional keyword arguments:

  • build - True if the model is being built for profiling

  • keras_model - The provided Keras model, if one was given

  • tflite_converter_settings - Dictionary of settings that will be given to TfliteConverter

  • post_process - True if post-processing is enabled

BEFORE_QUANTIZE = 'BEFORE_QUANTIZE'

//www.tensorflow.org/lite/convert>`_ is invoked

This has the additional keyword arguments:

  • converter - The TfliteConverter used to quantize the model

  • converter_dict - The TfliteConverter as converter_dict=dict(value=converter), update converter_dict['value'] to return a new converter by the event handler

Type:

Invoked during quantize_model before the `TfliteConverter <https

AFTER_QUANTIZE = 'AFTER_QUANTIZE'

Invoked during quantize_model after the TfliteConverter is invoked

This has the additional keyword arguments:

  • tflite_flatbuffer - The tflite flatbuffer binary array

  • tflite_flatbuffer_dict - The tflite_flatbuffer as tflite_flatbuffer_dict=dict(value=tflite_flatbuffer), update tflite_flatbuffer_dict['value'] to return a new tflite_flatbuffer by the event handler

  • update_archive - True if the model archive was updated with the quantized model

  • keras_model - The provided Keras model, if one was given

  • tflite_converter_settings - Dictionary of settings that will be given to TfliteConverter

QUANTIZE_SHUTDOWN = 'QUANTIZE_SHUTDOWN'

Invoked at the end of quantize_model

This has the additional keyword arguments:

  • tflite_model - The quantized TfliteModel instance

  • update_archive - True if the model archive was updated with the quantized model

  • keras_model - The provided Keras model, if one was given

  • tflite_converter_settings - Dictionary of settings that will be given to TfliteConverter

EVALUATE_STARTUP = 'EVALUATE_STARTUP'

Invoked at the beginning of evaluate_model

This has the additional keyword arguments:

  • tflite - True if should evaluate .tflite model, else evaluating Keras model

  • max_samples_per_class - This option places an upper limit on the number of samples per class that are used for evaluation

  • post_process - True if post-processing is enabled

EVALUATE_SHUTDOWN = 'EVALUATE_SHUTDOWN'

Invoked at the end of evaluate_model

This has the additional keyword arguments:

GENERATE_EVALUATE_PLOT = 'GENERATE_EVALUATE_PLOT'

Invoked when generating a plot during evaluate_model

This has the additional keyword arguments:

  • tflite - True if evaluating .tflite model, else evaluating Keras model

  • name - The name of the plot

  • fig - The matlibplot figure

AFTER_PROFILE = 'AFTER_PROFILE'

Invoked at the end of profile_model

This has the additional keyword arguments:

  • results - The generated ProfilingModelResults