mltk.core.MltkModelEvent¶
- class MltkModelEvent[source]¶
Events that are triggered at various stages of
MltkModel
execution.See
add_event_handler
for more details.Properties
Invoked before the
MltkModel
is fully loaded.Invoked after the
MltkModel
is fully loaded.Invoked at the beginning of
load_dataset
Invoked at the end of
load_dataset
Invoked at the beginning of
unload_dataset
Invoked at the end of
unload_dataset
Invoked at the end of
summarize_dataset
Invoked at the end of
summarize_model
Invoked at the beginning of
train_model
Invoked before
build_model_function
is calledInvoked after
build_model_function
is calledInvoked during
train_model
before Keras training starts.Invoked during
train_model
before Keras trainingInvoked during
train_model
after Keras trainingInvoked during
train_model
before the trained model is savedInvoked during
train_model
after the trained model is savedInvoked during
train_model
before the training results are savedInvoked during
train_model
after the training results are savedInvoked during
train_model
before the model archive is savedInvoked during
train_model
after the model archive is savedInvoked at the end of
train_model
Invoked at the beginning of
quantize_model
//www.tensorflow.org/lite/convert>`_ is invoked
Invoked during
quantize_model
after the TfliteConverter is invokedInvoked at the end of
quantize_model
Invoked at the beginning of
evaluate_model
Invoked at the end of
evaluate_model
Invoked when generating a plot during
evaluate_model
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)
, Updatesummary_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 calledThis event does not have any additional keyword arguments.
- AFTER_BUILD_TRAIN_MODEL = 'AFTER_BUILD_TRAIN_MODEL'¶
Invoked after
build_model_function
is calledThis 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 trainingThis has the additional keyword arguments:
fit_kwargs - Keyword args passed to KerasModel.fit()
- AFTER_TRAIN = 'AFTER_TRAIN'¶
Invoked during
train_model
after Keras trainingThis has the additional keyword arguments:
training_history - The value returned by KerasModel.fit()
- BEFORE_SAVE_TRAIN_MODEL = 'BEFORE_SAVE_TRAIN_MODEL'¶
Invoked during
train_model
before the trained model is savedThis 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)
, updatekeras_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 savedThis 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)
, updatekeras_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 savedThis 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 savedThis 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 savedThis 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 savedThis 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)
, updateconverter_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 invokedThis has the additional keyword arguments:
tflite_flatbuffer - The tflite flatbuffer binary array
tflite_flatbuffer_dict - The
tflite_flatbuffer
astflite_flatbuffer_dict=dict(value=tflite_flatbuffer)
, updatetflite_flatbuffer_dict['value']
to return a new tflite_flatbuffer by the event handlerupdate_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
instanceupdate_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:
results - The generated
EvaluationResults
- 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