Data Generation Configuration¶
- class model_compression_toolkit.data_generation.DataGenerationConfig(n_iter, optimizer, data_gen_batch_size, initial_lr, output_loss_multiplier, image_granularity=ImageGranularity.AllImages, scheduler_type=None, bn_alignment_loss_type=None, output_loss_type=None, data_init_type=None, layer_weighting_type=None, image_pipeline_type=None, image_normalization_type=None, extra_pixels=0, bn_layer_types=[], last_layer_types=[], image_clipping=True)¶
Configuration class for data generation.
Initialize the DataGenerationConfig.
- Parameters:
n_iter (int) – Number of iterations for data generation.
optimizer (Any) – The optimizer used for data generation.
data_gen_batch_size (int) – Batch size for data generation.
initial_lr (float) – Initial learning rate for the optimizer.
output_loss_multiplier (float) – Multiplier for the output loss.
image_granularity (ImageGranularity) – Granularity of image data generation. Defaults to ImageGranularity.AllImages.
scheduler_type (SchedulerType) – Type of scheduler for the optimizer. Defaults to None.
bn_alignment_loss_type (BatchNormAlignemntLossType) – Type of BatchNorm alignment loss. Defaults to None.
output_loss_type (OutputLossType) – Type of output loss. Defaults to None.
data_init_type (DataInitType) – Type of data initialization. Defaults to None.
layer_weighting_type (BNLayerWeightingType) – Type of layer weighting. Defaults to None.
image_pipeline_type (ImagePipelineType) – Type of image pipeline. Defaults to None.
image_normalization_type (ImageNormalizationType) – Type of image normalization. Defaults to None.
extra_pixels (Union[int, Tuple[int, int]]) – Extra pixels to add to the input image size. Defaults to 0.
bn_layer_types (List) – List of BatchNorm layer types. Defaults to [].
last_layer_types (List) – List of layer types. Defaults to [].
image_clipping (bool) – Flag to enable image clipping. Defaults to True.
ImageGranularity¶
- class model_compression_toolkit.data_generation.ImageGranularity(value)¶
An enum for choosing the image dependence granularity when generating images:
ImageWise
BatchWise
AllImages
SchedulerType¶
- class model_compression_toolkit.data_generation.SchedulerType(value)¶
An enum for choosing the scheduler type for the optimizer:
REDUCE_ON_PLATEAU - Use the ReduceOnPlateau scheduler.
STEP - Use the Step scheduler.
BatchNormAlignemntLossType¶
- class model_compression_toolkit.data_generation.BatchNormAlignemntLossType(value)¶
An enum for choosing the BatchNorm alignment loss type:
L2_SQUARE - Use L2 square loss for BatchNorm alignment.
OutputLossType¶
- class model_compression_toolkit.data_generation.OutputLossType(value)¶
An enum for choosing the output loss type: NONE - No output loss is applied. NEGATIVE_MIN_MAX_DIFF - Use the mean of the negative min-max difference as the output loss. INVERSE_MIN_MAX_DIFF - Use mean of the 1/(min-max) difference as the output loss. REGULARIZED_MIN_MAX_DIFF - Use regularized min-max difference as the output loss.
DataInitType¶
- class model_compression_toolkit.data_generation.DataInitType(value)¶
An enum for choosing the image dependence granularity when generating images:
Gaussian
Diverse
BNLayerWeightingType¶
- class model_compression_toolkit.data_generation.BNLayerWeightingType(value)¶
An enum for choosing the layer weighting type:
AVERAGE - Use the same weight per layer.
FIRST_LAYER_MULTIPLIER - Use a multiplier for the first layer, all other layers with the same weight.
GRAD - Use gradient-based layer weighting.
ImagePipelineType¶
- class model_compression_toolkit.data_generation.ImagePipelineType(value)¶
An enum for choosing the image pipeline type for image manipulation:
SMOOTHING_AND_AUGMENTATION - Apply a smoothing filter, then crop and flip the images.
IDENTITY - Do not apply any manipulation (identity transformation).
ImageNormalizationType¶
- class model_compression_toolkit.data_generation.ImageNormalizationType(value)¶
An enum for choosing the image normalization type:
TORCHVISION - Normalize the images using torchvision normalization.
KERAS_APPLICATIONS - Normalize the images using keras_applications imagenet normalization.
NO_NORMALIZATION - Do not apply any normalization.