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

options
list
Required

The list of options to choose from.

Returns

The stochastic expression.

Return type

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

mu
float
Required

The mean of the normal distribution.

sigma
float
Required

The standard deviation of the normal distribution.

Returns

The stochastic expression.

Return type

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

min_value
float
Required

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

max_value
float
Required

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

Returns

The stochastic expression.

Return type

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

mu
float
Required

The mean of the normal distribution.

sigma
float
Required

the standard deviation of the normal distribution.

Returns

The stochastic expression.

Return type

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

mu
float
Required

The mean of the normal distribution.

sigma
float
Required

The standard deviation of the normal distribution.

q
int
Required

The smoothing factor.

Returns

The stochastic expression.

Return type

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

min_value
float
Required

The minimum value in the range (inclusive).

max_value
float
Required

The maximum value in the range (inclusive).

q
int
Required

The smoothing factor.

Returns

The stochastic expression.

Return type

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

mu
float
Required

The mean of the normal distribution.

sigma
float
Required

The standard deviation of the normal distribution.

q
int
Required

The smoothing factor.

Returns

The stochastic expression.

Return type

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

min_value
float
Required

The minimum value in the range (inclusive).

max_value
float
Required

The maximum value in the range (inclusive).

q
int
Required

The smoothing factor.

Returns

The stochastic expression.

Return type

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

upper
int
Required

The exclusive upper bound for the range of integers.

Returns

The stochastic expression.

Return type

uniform

Specify a uniform distribution from which samples are taken.

uniform(min_value, max_value)

Parameters

min_value
float
Required

The minimum value in the range (inclusive).

max_value
float
Required

The maximum value in the range (inclusive).

Returns

The stochastic expression.

Return type