共用方式為


BanditPolicy 類別

根據寬限時間準則和評估的頻率和延遲間隔,定義早期終止原則。

繼承
azure.ai.ml.entities._job.sweep.early_termination_policy.EarlyTerminationPolicy
BanditPolicy

建構函式

BanditPolicy(*, delay_evaluation: int = 0, evaluation_interval: int = 0, slack_amount: float = 0, slack_factor: float = 0)

僅限關鍵字的參數

名稱 Description
delay_evaluation
int

延遲第一次評估的間隔數目。 預設為 0。

evaluation_interval
int

原則評估之間) 執行的間隔 (數目。 預設為 0。

slack_amount

最佳執行所允許的絕對距離。 預設為 0。

slack_factor

與最佳執行距離的允許距離比率。 預設為 0。

範例

在命令作業上設定超參數掃掠的 BanditPolicy 提早終止。


   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 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),
   )

   from azure.ai.ml.sweep import BanditPolicy

   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=BanditPolicy(slack_factor=0.15, evaluation_interval=1, delay_evaluation=10),
   )