Ecto-Trigger 1.0
|
Public Member Functions | |
__init__ (self, weights_file, representative_dataset, representative_example_nr) | |
quantise_model (self, output_path) | |
Public Attributes | |
weights_file = weights_file | |
representative_dataset = representative_dataset | |
representative_example_nr = representative_example_nr | |
model = self._load_model() | |
input_shape = self.model.input_shape[1:] | |
data_generator | |
Protected Member Functions | |
_load_model (self) | |
_test_quantised_model (self, tflite_quant_model) | |
A class to handle the quantization of a Keras model to TFLite with INT8 precision. Attributes: model (tf.keras.Model): The model to be quantised. representative_dataset (str): Path to the representative dataset for quantization.
__init__ | ( | self, | |
weights_file, | |||
representative_dataset, | |||
representative_example_nr ) |
Initialize the ModelQuantiser. Args: weights_file (str): Path to the Keras model weights file. representative_dataset (str): Directory containing the representative dataset.
|
protected |
Load the Keras model from the weights file. Returns: tf.keras.Model: Loaded model.
|
protected |
Test the quantised TFLite model by loading it into a TFLite interpreter. Args: tflite_quant_model (bytes): The quantised TFLite model.
quantise_model | ( | self, | |
output_path ) |
Quantise the model to TFLite format with INT8 precision. Args: output_path (str): Path to save the quantised TFLite model.
data_generator |
input_shape = self.model.input_shape[1:] |
model = self._load_model() |
representative_dataset = representative_dataset |
representative_example_nr = representative_example_nr |
weights_file = weights_file |