TruncationSelectionPolicy 類別
定義提早終止原則,以取消每個評估間隔的指定執行百分比。
- 繼承
-
azure.ai.ml.entities._job.sweep.early_termination_policy.EarlyTerminationPolicyTruncationSelectionPolicy
建構函式
TruncationSelectionPolicy(*, delay_evaluation: int = 0, evaluation_interval: int = 0, truncation_percentage: int = 0)
僅限關鍵字的參數
名稱 | Description |
---|---|
delay_evaluation
|
延遲第一次評估的間隔數目。 預設為 0。 |
evaluation_interval
|
原則評估之間) 執行的間隔 (數目。 預設為 0。 |
truncation_percentage
|
要在每個評估間隔取消的執行百分比。 預設為 0。 |
範例
使用 TruncationStoppingPolicy 設定超參數掃掠作業的早期終止原則
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 QUniform, TruncationSelectionPolicy, Uniform
job_for_sweep = job(
kernel=Uniform(min_value=0.0005, max_value=0.005),
penalty=QUniform(min_value=0.05, max_value=0.75, q=1),
)
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=TruncationSelectionPolicy(delay_evaluation=5, evaluation_interval=2),
)