你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

RandomSamplingAlgorithm 类

随机采样算法。

继承
azure.ai.ml.entities._job.sweep.sampling_algorithm.SamplingAlgorithm
RandomSamplingAlgorithm

构造函数

RandomSamplingAlgorithm(*, rule: str | None = None, seed: int | None = None, logbase: float | str | None = None)

仅限关键字的参数

名称 说明
rule

随机算法的特定类型。 接受的值为:“random”和“sobol”。

seed
int

随机数生成的种子。

logbase

一个正数或字符串格式的数字“e”,用作基于对数的随机采样的基数。

示例

为 SweepJob 分配随机采样算法


   from azure.ai.ml.entities import CommandJob
   from azure.ai.ml.sweep import RandomSamplingAlgorithm, SweepJob, SweepJobLimits

   command_job = CommandJob(
       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",
   )

   sweep = SweepJob(
       sampling_algorithm=RandomSamplingAlgorithm(seed=999, rule="sobol", logbase="e"),
       trial=command_job,
       search_space={"ss": Choice(type="choice", values=[{"space1": True}, {"space2": True}])},
       inputs={"input1": {"file": "top_level.csv", "mode": "ro_mount"}},
       compute="top_level",
       limits=SweepJobLimits(trial_timeout=600),
   )