ImageModelSettingsClassification Class

Model settings for AutoML Image Classification tasks.

Inheritance
azure.ai.ml.entities._job.automl.image.image_model_settings.ImageModelDistributionSettings
ImageModelSettingsClassification

Constructor

ImageModelSettingsClassification(*, advanced_settings: str | None = None, ams_gradient: bool | None = None, beta1: float | None = None, beta2: float | None = None, checkpoint_frequency: int | None = None, checkpoint_run_id: str | None = None, distributed: bool | None = None, early_stopping: bool | None = None, early_stopping_delay: int | None = None, early_stopping_patience: int | None = None, enable_onnx_normalization: bool | None = None, evaluation_frequency: int | None = None, gradient_accumulation_step: int | None = None, layers_to_freeze: int | None = None, learning_rate: float | None = None, learning_rate_scheduler: LearningRateScheduler | None = None, model_name: str | None = None, momentum: float | None = None, nesterov: bool | None = None, number_of_epochs: int | None = None, number_of_workers: int | None = None, optimizer: StochasticOptimizer | None = None, random_seed: int | None = None, step_lr_gamma: float | None = None, step_lr_step_size: int | None = None, training_batch_size: int | None = None, validation_batch_size: int | None = None, warmup_cosine_lr_cycles: float | None = None, warmup_cosine_lr_warmup_epochs: int | None = None, weight_decay: float | None = None, training_crop_size: int | None = None, validation_crop_size: int | None = None, validation_resize_size: int | None = None, weighted_loss: int | None = None, **kwargs: Any)

Parameters

Name Description
advanced_settings
Required
str

Settings for advanced scenarios.

ams_gradient
Required

Enable AMSGrad when optimizer is 'adam' or 'adamw'.

beta1
Required

Value of 'beta1' when optimizer is 'adam' or 'adamw'. Must be a float in the range [0, 1].

beta2
Required

Value of 'beta2' when optimizer is 'adam' or 'adamw'. Must be a float in the range [0, 1].

checkpoint_frequency
Required
int

Frequency to store model checkpoints. Must be a positive integer.

checkpoint_run_id
Required
str

The id of a previous run that has a pretrained checkpoint for incremental training.

distributed
Required

Whether to use distributed training.

early_stopping
Required

Enable early stopping logic during training.

early_stopping_delay
Required
int

Minimum number of epochs or validation evaluations to wait before primary metric improvement is tracked for early stopping. Must be a positive integer.

early_stopping_patience
Required
int

Minimum number of epochs or validation evaluations with no primary metric improvement before the run is stopped. Must be a positive integer.

enable_onnx_normalization
Required

Enable normalization when exporting ONNX model.

evaluation_frequency
Required
int

Frequency to evaluate validation dataset to get metric scores. Must be a positive integer.

gradient_accumulation_step
Required
int

Gradient accumulation means running a configured number of "GradAccumulationStep" steps without updating the model weights while accumulating the gradients of those steps, and then using the accumulated gradients to compute the weight updates. Must be a positive integer.

layers_to_freeze
Required
int

Number of layers to freeze for the model. Must be a positive integer. For instance, passing 2 as value for 'seresnext' means freezing layer0 and layer1. For a full list of models supported and details on layer freeze, please see: https://docs.microsoft.com/en-us/azure/machine-learning/how-to-auto-train-image-models.

learning_rate
Required

Initial learning rate. Must be a float in the range [0, 1].

learning_rate_scheduler
Required

Type of learning rate scheduler. Must be 'warmup_cosine' or 'step'. Possible values include: "None", "WarmupCosine", "Step".

model_name
Required
str

Name of the model to use for training. For more information on the available models please visit the official documentation: https://docs.microsoft.com/en-us/azure/machine-learning/how-to-auto-train-image-models.

momentum
Required

Value of momentum when optimizer is 'sgd'. Must be a float in the range [0, 1].

nesterov
Required

Enable nesterov when optimizer is 'sgd'.

number_of_epochs
Required
int

Number of training epochs. Must be a positive integer.

number_of_workers
Required
int

Number of data loader workers. Must be a non-negative integer.

optimizer
Required

Type of optimizer. Possible values include: "None", "Sgd", "Adam", "Adamw".

random_seed
Required
int

Random seed to be used when using deterministic training.

step_lr_gamma
Required

Value of gamma when learning rate scheduler is 'step'. Must be a float in the range [0, 1].

step_lr_step_size
Required
int

Value of step size when learning rate scheduler is 'step'. Must be a positive integer.

training_batch_size
Required
int

Training batch size. Must be a positive integer.

validation_batch_size
Required
int

Validation batch size. Must be a positive integer.

warmup_cosine_lr_cycles
Required

Value of cosine cycle when learning rate scheduler is 'warmup_cosine'. Must be a float in the range [0, 1].

warmup_cosine_lr_warmup_epochs
Required
int

Value of warmup epochs when learning rate scheduler is 'warmup_cosine'. Must be a positive integer.

weight_decay
Required

Value of weight decay when optimizer is 'sgd', 'adam', or 'adamw'. Must be a float in the range[0, 1].

training_crop_size
Required
int

Image crop size that is input to the neural network for the training dataset. Must be a positive integer.

validation_crop_size
Required
int

Image crop size that is input to the neural network for the validation dataset. Must be a positive integer.

validation_resize_size
Required
int

Image size to which to resize before cropping for validation dataset. Must be a positive integer.

weighted_loss
Required
int

Weighted loss. The accepted values are 0 for no weighted loss. 1 for weighted loss with sqrt.(class_weights). 2 for weighted loss with class_weights. Must be 0 or 1 or 2.

Keyword-Only Parameters

Name Description
advanced_settings
Required
ams_gradient
Required
beta1
Required
beta2
Required
checkpoint_frequency
Required
checkpoint_run_id
Required
distributed
Required
early_stopping
Required
early_stopping_delay
Required
early_stopping_patience
Required
enable_onnx_normalization
Required
evaluation_frequency
Required
gradient_accumulation_step
Required
layers_to_freeze
Required
learning_rate
Required
learning_rate_scheduler
Required
model_name
Required
momentum
Required
nesterov
Required
number_of_epochs
Required
number_of_workers
Required
optimizer
Required
random_seed
Required
step_lr_gamma
Required
step_lr_step_size
Required
training_batch_size
Required
validation_batch_size
Required
warmup_cosine_lr_cycles
Required
warmup_cosine_lr_warmup_epochs
Required
weight_decay
Required
training_crop_size
Required
validation_crop_size
Required
validation_resize_size
Required
weighted_loss
Required

Examples

Defining the automl image classification model settings.


   from azure.ai.ml import automl

   image_classification_model_settings = automl.ImageModelSettingsClassification(
       checkpoint_frequency=5,
       early_stopping=False,
       gradient_accumulation_step=2,
   )