ImageClassificationSearchSpace Class
Search space for AutoML Image Classification and Image Classification Multilabel tasks.
- Inheritance
-
azure.ai.ml.entities._mixins.RestTranslatableMixinImageClassificationSearchSpace
Constructor
ImageClassificationSearchSpace(*, ams_gradient: bool | SweepDistribution | None = None, beta1: float | SweepDistribution | None = None, beta2: float | SweepDistribution | None = None, distributed: bool | SweepDistribution | None = None, early_stopping: bool | SweepDistribution | None = None, early_stopping_delay: int | SweepDistribution | None = None, early_stopping_patience: int | SweepDistribution | None = None, enable_onnx_normalization: bool | SweepDistribution | None = None, evaluation_frequency: int | SweepDistribution | None = None, gradient_accumulation_step: int | SweepDistribution | None = None, layers_to_freeze: int | SweepDistribution | None = None, learning_rate: float | SweepDistribution | None = None, learning_rate_scheduler: str | SweepDistribution | None = None, model_name: str | SweepDistribution | None = None, momentum: float | SweepDistribution | None = None, nesterov: bool | SweepDistribution | None = None, number_of_epochs: int | SweepDistribution | None = None, number_of_workers: int | SweepDistribution | None = None, optimizer: str | SweepDistribution | None = None, random_seed: int | SweepDistribution | None = None, step_lr_gamma: float | SweepDistribution | None = None, step_lr_step_size: int | SweepDistribution | None = None, training_batch_size: int | SweepDistribution | None = None, validation_batch_size: int | SweepDistribution | None = None, warmup_cosine_lr_cycles: float | SweepDistribution | None = None, warmup_cosine_lr_warmup_epochs: int | SweepDistribution | None = None, weight_decay: float | SweepDistribution | None = None, training_crop_size: int | SweepDistribution | None = None, validation_crop_size: int | SweepDistribution | None = None, validation_resize_size: int | SweepDistribution | None = None, weighted_loss: int | SweepDistribution | None = None)
Parameters
Name | Description |
---|---|
ams_gradient
Required
|
bool or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
Enable AMSGrad when optimizer is 'adam' or 'adamw'. |
beta1
Required
|
float or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
Value of 'beta1' when optimizer is 'adam' or 'adamw'. Must be a float in the range [0, 1]. |
beta2
Required
|
float or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
Value of 'beta2' when optimizer is 'adam' or 'adamw'. Must be a float in the range [0, 1]. |
distributed
Required
|
bool or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
Whether to use distributer training. |
early_stopping
Required
|
bool or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
Enable early stopping logic during training. |
early_stopping_delay
Required
|
int or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
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 or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
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
|
bool or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
Enable normalization when exporting ONNX model. |
evaluation_frequency
Required
|
int or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
Frequency to evaluate validation dataset to get metric scores. Must be a positive integer. |
gradient_accumulation_step
Required
|
int or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
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 or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
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/reference-automl-images-hyperparameters#model-agnostic-hyperparameters. # pylint: disable=line-too-long |
learning_rate
Required
|
float or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
Initial learning rate. Must be a float in the range [0, 1]. |
learning_rate_scheduler
Required
|
str or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
Type of learning rate scheduler. Must be 'warmup_cosine' or 'step'. |
model_name
Required
|
str or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
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
|
float or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
Value of momentum when optimizer is 'sgd'. Must be a float in the range [0, 1]. |
nesterov
Required
|
bool or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
Enable nesterov when optimizer is 'sgd'. |
number_of_epochs
Required
|
int or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
Number of training epochs. Must be a positive integer. |
number_of_workers
Required
|
int or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
Number of data loader workers. Must be a non-negative integer. |
optimizer
Required
|
str or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
Type of optimizer. Must be either 'sgd', 'adam', or 'adamw'. |
random_seed
Required
|
int or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
Random seed to be used when using deterministic training. |
step_lr_gamma
Required
|
float or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
Value of gamma when learning rate scheduler is 'step'. Must be a float in the range [0, 1]. |
step_lr_step_size
Required
|
int or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
Value of step size when learning rate scheduler is 'step'. Must be a positive integer. |
training_batch_size
Required
|
int or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
Training batch size. Must be a positive integer. |
validation_batch_size
Required
|
int or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
Validation batch size. Must be a positive integer. |
warmup_cosine_lr_cycles
Required
|
float or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
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 or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
Value of warmup epochs when learning rate scheduler is 'warmup_cosine'. Must be a positive integer. |
weight_decay
Required
|
float or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
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 or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
Image crop size that is input to the neural network for the training dataset. Must be a positive integer. |
validation_crop_size
Required
|
int or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
Image crop size that is input to the neural network for the validation dataset. Must be a positive integer. |
validation_resize_size
Required
|
int or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
Image size to which to resize before cropping for validation dataset. Must be a positive integer. |
weighted_loss
Required
|
int or
<xref:azure.ai.ml.entities._job.sweep.search_space.SweepDistribution>
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 |
---|---|
ams_gradient
Required
|
|
beta1
Required
|
|
beta2
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 an automl image classification search space
from azure.ai.ml import automl
from azure.ai.ml.sweep import Uniform, Choice
image_classification_search_space = automl.ImageClassificationSearchSpace(
model_name="vitb16r224",
number_of_epochs=Choice([15, 30]),
weight_decay=Uniform(0.01, 0.1),
)
Azure SDK for Python