Share via


MedianStoppingPolicy Klas

Definieert een beleid voor vroegtijdige beëindiging op basis van een voorlopig gemiddelde van de primaire metrische gegevens van alle uitvoeringen.

Overname
azure.ai.ml.entities._job.sweep.early_termination_policy.EarlyTerminationPolicy
MedianStoppingPolicy

Constructor

MedianStoppingPolicy(*, delay_evaluation: int = 0, evaluation_interval: int = 1)

Keyword-Only Parameters

Name Description
delay_evaluation
int

Het aantal intervallen waarmee de eerste evaluatie moet worden vertraagd. De standaardwaarde is 0.

evaluation_interval
int

Interval (aantal uitvoeringen) tussen beleidsevaluaties. Standaardwaarde is 1.

standaardwaarde: 1

Voorbeelden

Een beleid voor vroegtijdige beëindiging configureren voor een hyperparameter-sweeptaak met behulp van MedianStoppingPolicy


   from azure.ai.ml import command

   job = command(
       inputs=dict(kernel="linear", penalty=1.0),
       compute=cpu_cluster,
       environment=f"{job_env.name}:{job_env.version}",
       code="./scripts",
       command="python scripts/train.py --kernel $kernel --penalty $penalty",
       experiment_name="sklearn-iris-flowers",
   )

   # we can reuse an existing Command Job as a function that we can apply inputs to for the sweep configurations
   from azure.ai.ml.sweep import MedianStoppingPolicy, Uniform

   job_for_sweep = job(
       kernel=Uniform(min_value=0.0005, max_value=0.005),
       penalty=Uniform(min_value=0.9, max_value=0.99),
   )

   sweep_job = job_for_sweep.sweep(
       sampling_algorithm="random",
       primary_metric="best_val_acc",
       goal="Maximize",
       max_total_trials=8,
       max_concurrent_trials=4,
       early_termination_policy=MedianStoppingPolicy(delay_evaluation=5, evaluation_interval=2),
   )