parameter_expressions Module

Defines functions that can be used in HyperDrive to describe a hyperparameter search space.

These functions are used to specify different types of hyperparameter distributions. The distributions are defined when you configure sampling for a hyperparameter sweep. For example, when you use the RandomParameterSampling class, you can choose to sample from a set of discrete values or a distribution of continuous values. In this case, you could use the choice function to generate a discrete set of values and uniform function to generate a distribution of continuous values.

For examples of using these functions, see the tutorial: https://docs.microsoft.com/azure/machine-learning/how-to-tune-hyperparameters.

Functions

choice

Specify a discrete set of options to sample from.

choice(*options)

Parameters

Name Description
options
Required

The list of options to choose from.

Returns

Type Description

The stochastic expression.

lognormal

Specify a value drawn according to exp(normal(mu, sigma)).

The logarithm of the return value is normally distributed. When optimizing, this variable is constrained to be positive.

lognormal(mu, sigma)

Parameters

Name Description
mu
Required

The mean of the normal distribution.

sigma
Required

The standard deviation of the normal distribution.

Returns

Type Description

The stochastic expression.

loguniform

Specify a log uniform distribution.

A value is drawn according to exp(uniform(min_value, max_value)) so that the logarithm of the return value is uniformly distributed. When optimizing, this variable is constrained to the interval [exp(min_value), exp(max_value)]

loguniform(min_value, max_value)

Parameters

Name Description
min_value
Required

The minimum value in the range will be exp(min_value)(inclusive).

max_value
Required

The maximum value in the range will be exp(max_value) (inclusive).

Returns

Type Description

The stochastic expression.

normal

Specify a real value that is normally-distributed with mean mu and standard deviation sigma.

When optimizing, this is an unconstrained variable.

normal(mu, sigma)

Parameters

Name Description
mu
Required

The mean of the normal distribution.

sigma
Required

the standard deviation of the normal distribution.

Returns

Type Description

The stochastic expression.

qlognormal

Specify a value like round(exp(normal(mu, sigma)) / q) * q.

Suitable for a discrete variable with respect to which the objective is smooth and gets smoother with the size of the variable, which is bounded from one side.

qlognormal(mu, sigma, q)

Parameters

Name Description
mu
Required

The mean of the normal distribution.

sigma
Required

The standard deviation of the normal distribution.

q
Required
int

The smoothing factor.

Returns

Type Description

The stochastic expression.

qloguniform

Specify a uniform distribution of the form round(exp(uniform(min_value, max_value) / q) * q.

This is suitable for a discrete variable with respect to which the objective is "smooth", and gets smoother with the size of the value, but which should be bounded both above and below.

qloguniform(min_value, max_value, q)

Parameters

Name Description
min_value
Required

The minimum value in the range (inclusive).

max_value
Required

The maximum value in the range (inclusive).

q
Required
int

The smoothing factor.

Returns

Type Description

The stochastic expression.

qnormal

Specify a value like round(normal(mu, sigma) / q) * q.

Suitable for a discrete variable that probably takes a value around mu, but is fundamentally unbounded.

qnormal(mu, sigma, q)

Parameters

Name Description
mu
Required

The mean of the normal distribution.

sigma
Required

The standard deviation of the normal distribution.

q
Required
int

The smoothing factor.

Returns

Type Description

The stochastic expression.

quniform

Specify a uniform distribution of the form round(uniform(min_value, max_value) / q) * q.

This is suitable for a discrete value with respect to which the objective is still somewhat "smooth", but which should be bounded both above and below.

quniform(min_value, max_value, q)

Parameters

Name Description
min_value
Required

The minimum value in the range (inclusive).

max_value
Required

The maximum value in the range (inclusive).

q
Required
int

The smoothing factor.

Returns

Type Description

The stochastic expression.

randint

Specify a set of random integers in the range [0, upper).

The semantics of this distribution is that there is no more correlation in the loss function between nearby integer values, as compared with more distant integer values. This is an appropriate distribution for describing random seeds for example. If the loss function is probably more correlated for nearby integer values, then you should probably use one of the "quantized" continuous distributions, such as either quniform, qloguniform, qnormal or qlognormal.

randint(upper)

Parameters

Name Description
upper
Required
int

The exclusive upper bound for the range of integers.

Returns

Type Description

The stochastic expression.

uniform

Specify a uniform distribution from which samples are taken.

uniform(min_value, max_value)

Parameters

Name Description
min_value
Required

The minimum value in the range (inclusive).

max_value
Required

The maximum value in the range (inclusive).

Returns

Type Description

The stochastic expression.