示例#1
0
def get_parameter_distribution(distribution, **kwargs):
    if "choice" in distribution.lower():
        parameter_distr = choice(
            kwargs.get("options", [])
        )
    elif "randint" in distribution.lower():
        parameter_distr = randint(
            upper=kwargs.get("upper", None)
        )
    elif "uniform" in distribution.lower():
        parameter_distr = uniform(
            min_value=kwargs.get("min_value", None),
            max_value=kwargs.get("max_value", None)
        )
    elif "quniform" in distribution.lower():
        parameter_distr = quniform(
            min_value=kwargs.get("min_value", None),
            max_value=kwargs.get("max_value", None),
            q=kwargs.get("q", None)
        )
    elif "loguniform" in distribution.lower():
        parameter_distr = loguniform(
            min_value=kwargs.get("min_value", None),
            max_value=kwargs.get("max_value", None),
        )
    elif "qloguniform" in distribution.lower():
        parameter_distr = qloguniform(
            min_value=kwargs.get("min_value", None),
            max_value=kwargs.get("max_value", None),
            q=kwargs.get("q", None)
        )
    elif "normal" in distribution.lower():
        parameter_distr = normal(
            mu=kwargs.get("mu", None),
            sigma=kwargs.get("sigma", None)
        )
    elif "qnormal" in distribution.lower():
        parameter_distr = qnormal(
            mu=kwargs.get("mu", None),
            sigma=kwargs.get("sigma", None),
            q=kwargs.get("q", None)
        )
    elif "lognormal" in distribution.lower():
        parameter_distr = lognormal(
            mu=kwargs.get("mu", None),
            sigma=kwargs.get("sigma", None)
        )
    elif "qlognormal" in distribution.lower():
        parameter_distr = qlognormal(
            mu=kwargs.get("mu", None),
            sigma=kwargs.get("sigma", None),
            q=kwargs.get("q", None)
        )
    else:
        parameter_distr = None
        raise RunConfigurationException(f"Parameter distribution for parameter not defined in settings. Please choose between \'choice\', \'randint\', \'uniform\', \'quniform\', \'loguniform\', \'qloguniform\', \'normal\', \'qnormal\', \'lognormal\' and \'qlognormal\'")
    return parameter_distr
示例#2
0
def get_parameter_distribution(parameter_name, parameter_setting):
    if "choice" in parameter_setting["distribution"]:
        parameter_distr = choice(parameter_setting["parameters"]["options"])
    elif "randint" in parameter_setting["distribution"]:
        parameter_distr = randint(
            upper=parameter_setting["parameters"]["upper"])
    elif "uniform" in parameter_setting["distribution"]:
        parameter_distr = uniform(
            min_value=parameter_setting["parameters"]["min_value"],
            max_value=parameter_setting["parameters"]["max_value"])
    elif "quniform" in parameter_setting["distribution"]:
        parameter_distr = quniform(
            min_value=parameter_setting["parameters"]["min_value"],
            max_value=parameter_setting["parameters"]["max_value"],
            q=parameter_setting["parameters"]["q"])
    elif "loguniform" in parameter_setting["distribution"]:
        parameter_distr = loguniform(
            min_value=parameter_setting["parameters"]["min_value"],
            max_value=parameter_setting["parameters"]["max_value"])
    elif "qloguniform" in parameter_setting["distribution"]:
        parameter_distr = qloguniform(
            min_value=parameter_setting["parameters"]["min_value"],
            max_value=parameter_setting["parameters"]["max_value"],
            q=parameter_setting["parameters"]["q"])
    elif "normal" in parameter_setting["distribution"]:
        parameter_distr = normal(
            mu=parameter_setting["parameters"]["mu"],
            sigma=parameter_setting["parameters"]["sigma"])
    elif "qnormal" in parameter_setting["distribution"]:
        parameter_distr = qnormal(
            mu=parameter_setting["parameters"]["mu"],
            sigma=parameter_setting["parameters"]["sigma"],
            q=parameter_setting["parameters"]["q"])
    elif "lognormal" in parameter_setting["distribution"]:
        parameter_distr = lognormal(
            mu=parameter_setting["parameters"]["mu"],
            sigma=parameter_setting["parameters"]["sigma"])
    elif "qlognormal" in parameter_setting["distribution"]:
        parameter_distr = qlognormal(
            mu=parameter_setting["parameters"]["mu"],
            sigma=parameter_setting["parameters"]["sigma"],
            q=parameter_setting["parameters"]["q"])
    else:
        parameter_distr = None
        raise RunConfigurationException(
            "Parameter distribution for parameter {} not defined in settings. Please choose between \'choice\', \'randint\', \'uniform\', \'quniform\', \'loguniform\', \'qloguniform\', \'normal\', \'qnormal\', \'lognormal\' and \'qlognormal\'"
            .format(parameter_name))
    return parameter_distr
示例#3
0
# -loguniform


#continuous hyperparams

#normal
#uniform
#lognormal
#loguniform


from azureml.train.hyperdrive import choice, normal

param_sapce = {
    '--batch_size': choice(10,12,15),
    '--learning_rate': normal(10,3)
}


#configuring sample - grid,random, baysian

from azureml.train.hyperdrive import GridParameterSampling, RandomParameterSampling, BayesianParameterSampling


param_sampling = GridParameterSampling(param_sapce)


#configuring the early stopping 

- bandit policy            -> BanditPolicy(slack_amount = 0.2, evaluation_interval = 1, delay_evaluation = 5)
- median stopping policy   -> MedianStoppingPolicy(evaluation_interval = 1, delay_evaluation = 5)