ImageClassificationMultilabelJob Class

Configuration for AutoML multi-label Image Classification job.

Inheritance
azure.ai.ml.entities._job.automl.image.automl_image_classification_base.AutoMLImageClassificationBase
ImageClassificationMultilabelJob

Constructor

ImageClassificationMultilabelJob(*, primary_metric: str | ClassificationMultilabelPrimaryMetrics | None = None, **kwargs: Any)

Parameters

Name Description
primary_metric
Required

The primary metric to use for optimization.

kwargs
Required

Job-specific arguments.

Keyword-Only Parameters

Name Description
primary_metric
Required

Examples

creating an automl image classification multilabel job


   from azure.ai.ml import automl, Input
   from azure.ai.ml.constants import AssetTypes
   from azure.ai.ml.automl import ClassificationMultilabelPrimaryMetrics

   image_classification_multilabel_job = automl.ImageClassificationMultilabelJob(
       experiment_name="my_experiment",
       compute="my_compute",
       training_data=Input(type=AssetTypes.MLTABLE, path="./training-mltable-folder"),
       validation_data=Input(type=AssetTypes.MLTABLE, path="./validation-mltable-folder"),
       target_column_name="terms",
       primary_metric=ClassificationMultilabelPrimaryMetrics.IOU,
       tags={"my_custom_tag": "My custom value"},
   )

Methods

dump

Dumps the job content into a file in YAML format.

extend_search_space

Add Search space for AutoML Image Classification and Image Classification Multilabel tasks.

set_data

Data settings for all AutoML Image jobs.

set_limits

Limit settings for all AutoML Image Jobs.

set_sweep

Sweep settings for all AutoML Image jobs.

set_training_parameters

Setting Image training parameters for AutoML Image Classification and Image Classification Multilabel tasks.

dump

Dumps the job content into a file in YAML format.

dump(dest: str | PathLike | IO, **kwargs: Any) -> None

Parameters

Name Description
dest
Required
Union[<xref:PathLike>, str, IO[AnyStr]]

The local path or file stream to write the YAML content to. If dest is a file path, a new file will be created. If dest is an open file, the file will be written to directly.

Exceptions

Type Description

Raised if dest is a file path and the file already exists.

Raised if dest is an open file and the file is not writable.

extend_search_space

Add Search space for AutoML Image Classification and Image Classification Multilabel tasks.

extend_search_space(value: SearchSpace | List[SearchSpace]) -> None

Parameters

Name Description
value
Required

specify either an instance of ImageClassificationSearchSpace or list of ImageClassificationSearchSpace for searching through the parameter space

Exceptions

Type Description

Raised if dest is a file path and the file already exists.

Raised if dest is an open file and the file is not writable.

set_data

Data settings for all AutoML Image jobs.

set_data(*, training_data: Input, target_column_name: str, validation_data: Input | None = None, validation_data_size: float | None = None) -> None

Keyword-Only Parameters

Name Description
training_data

Required. Training data.

target_column_name

Required. Target column name.

validation_data

Optional. Validation data.

validation_data_size

Optional. The fraction of training dataset that needs to be set aside for validation purpose. Values should be in range (0.0 , 1.0). Applied only when validation dataset is not provided.

Returns

Type Description

None

Exceptions

Type Description

Raised if dest is a file path and the file already exists.

Raised if dest is an open file and the file is not writable.

set_limits

Limit settings for all AutoML Image Jobs.

set_limits(*, max_concurrent_trials: int | None = None, max_trials: int | None = None, timeout_minutes: int | None = None) -> None

Keyword-Only Parameters

Name Description
max_concurrent_trials

Maximum number of trials to run concurrently.

max_trials

Maximum number of trials to run. Defaults to None.

timeout_minutes

AutoML job timeout.

Returns

Type Description

None

Exceptions

Type Description

Raised if dest is a file path and the file already exists.

Raised if dest is an open file and the file is not writable.

set_sweep

Sweep settings for all AutoML Image jobs.

set_sweep(*, sampling_algorithm: str | Random | Grid | Bayesian, early_termination: BanditPolicy | MedianStoppingPolicy | TruncationSelectionPolicy | None = None) -> None

Keyword-Only Parameters

Name Description
sampling_algorithm

Required. Type of the hyperparameter sampling algorithms. Possible values include: "Grid", "Random", "Bayesian".

early_termination

Type of early termination policy.

Returns

Type Description

None

Exceptions

Type Description

Raised if dest is a file path and the file already exists.

Raised if dest is an open file and the file is not writable.

set_training_parameters

Setting Image training parameters for AutoML Image Classification and Image Classification Multilabel tasks.

set_training_parameters(*, 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: str | 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: str | 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) -> None

Keyword-Only Parameters

Name Description
advanced_settings
str

Settings for advanced scenarios.

ams_gradient

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

beta1

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

beta2

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

checkpoint_frequency
int

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

checkpoint_run_id
str

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

distributed

Whether to use distributed training.

early_stopping

Enable early stopping logic during training.

early_stopping_delay
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
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

Enable normalization when exporting ONNX model.

evaluation_frequency
int

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

gradient_accumulation_step
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

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

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

learning_rate_scheduler

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

model_name

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

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

nesterov

Enable nesterov when optimizer is 'sgd'.

number_of_epochs
int

Number of training epochs. Must be a positive integer.

number_of_workers
int

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

optimizer

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

random_seed
int

Random seed to be used when using deterministic training.

step_lr_gamma

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

step_lr_step_size
int

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

training_batch_size
int

Training batch size. Must be a positive integer.

validation_batch_size
int

Validation batch size. Must be a positive integer.

warmup_cosine_lr_cycles

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
int

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

weight_decay

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

training_crop_size
int

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

validation_crop_size
int

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

validation_resize_size
int

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

weighted_loss
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.

Exceptions

Type Description

Raised if dest is a file path and the file already exists.

Raised if dest is an open file and the file is not writable.

Attributes

base_path

The base path of the resource.

Returns

Type Description
str

The base path of the resource.

creation_context

The creation context of the resource.

Returns

Type Description

The creation metadata for the resource.

id

The resource ID.

Returns

Type Description

The global ID of the resource, an Azure Resource Manager (ARM) ID.

inputs

limits

Returns the limit settings for all AutoML Image jobs.

Returns

Type Description

The limit settings.

log_files

Job output files.

Returns

Type Description

The dictionary of log names and URLs.

log_verbosity

Returns the verbosity of the logger.

Returns

Type Description
<xref:azure.ai.ml._restclient.v2023_04_01_preview.models.LogVerbosity>

The log verbosity.

outputs

primary_metric

search_space

List[~azure.ai.ml.automl.ImageClassificationSearchSpace] :return: Search space for AutoML Image Classification and Image Classification Multilabel tasks.

status

The status of the job.

Common values returned include "Running", "Completed", and "Failed". All possible values are:

  • NotStarted - This is a temporary state that client-side Run objects are in before cloud submission.

  • Starting - The Run has started being processed in the cloud. The caller has a run ID at this point.

  • Provisioning - On-demand compute is being created for a given job submission.

  • Preparing - The run environment is being prepared and is in one of two stages:

    • Docker image build

    • conda environment setup

  • Queued - The job is queued on the compute target. For example, in BatchAI, the job is in a queued state

    while waiting for all the requested nodes to be ready.

  • Running - The job has started to run on the compute target.

  • Finalizing - User code execution has completed, and the run is in post-processing stages.

  • CancelRequested - Cancellation has been requested for the job.

  • Completed - The run has completed successfully. This includes both the user code execution and run

    post-processing stages.

  • Failed - The run failed. Usually the Error property on a run will provide details as to why.

  • Canceled - Follows a cancellation request and indicates that the run is now successfully cancelled.

  • NotResponding - For runs that have Heartbeats enabled, no heartbeat has been recently sent.

Returns

Type Description

Status of the job.

studio_url

Azure ML studio endpoint.

Returns

Type Description

The URL to the job details page.

sweep

Returns the sweep settings for all AutoML Image jobs.

Returns

Type Description

The sweep settings.

task_type

Get task type.

Returns

Type Description
str

The type of task to run. Possible values include: "classification", "regression", "forecasting".

test_data

Get test data.

Returns

Type Description

Test data input

training_data

Get training data.

Returns

Type Description

Training data input

training_parameters

~azure.ai.ml.automl.ImageModelSettingsClassification :return: Training parameters for AutoML Image Classification and Image Classification Multilabel tasks.

type

The type of the job.

Returns

Type Description

The type of the job.

validation_data

Get validation data.

Returns

Type Description

Validation data input