hyperoptax.spaces#

Classes

LinearSpace(lower_bound, upper_bound)

Uniform continuous space over [lower_bound, upper_bound].

LogSpace(lower_bound, upper_bound[, base])

Log-uniform continuous space over [lower_bound, upper_bound].

hyperoptax.spaces.log_transform(x, base)[source]#
Parameters:
Return type:

float

class hyperoptax.spaces.Space[source]#

Abstract base class for hyperparameter search spaces.

abstract sample(key)[source]#
Parameters:

key (PRNGKey)

Return type:

Array

transform(value)[source]#
__init__()#
Return type:

None

class hyperoptax.spaces.LinearSpace(lower_bound, upper_bound)[source]#

Uniform continuous space over [lower_bound, upper_bound].

Parameters:
lower_bound#

Inclusive lower bound of the interval.

Type:

float

upper_bound#

Exclusive upper bound of the interval.

Type:

float

lower_bound: float#
upper_bound: float#
sample(key)[source]#
Parameters:

key (PRNGKey)

Return type:

float

__init__(lower_bound, upper_bound)#
Parameters:
Return type:

None

class hyperoptax.spaces.DiscreteSpace(values)[source]#

Discrete space over a fixed set of values.

Samples uniformly from values. transform snaps any continuous value to the nearest element, which is useful when discrete candidates are generated via continuous optimization (e.g. in BayesianSearch).

Parameters:

values (tuple)

values#

Tuple of candidate values to sample from.

Type:

tuple

values: tuple#
property lower_bound: float#
property upper_bound: float#
sample(key)[source]#
Parameters:

key (PRNGKey)

Return type:

float

transform(value)[source]#
Return type:

Array

__init__(values)#
Parameters:

values (tuple)

Return type:

None

class hyperoptax.spaces.LogSpace(lower_bound, upper_bound, base=10)[source]#

Log-uniform continuous space over [lower_bound, upper_bound].

Samples uniformly in log space so that each order of magnitude receives equal probability mass. Useful for learning rates and other scale parameters that span several orders of magnitude.

Parameters:
lower_bound#

Inclusive lower bound (in original scale, e.g. 1e-5).

Type:

float

upper_bound#

Exclusive upper bound (in original scale, e.g. 1e-1).

Type:

float

base#

Logarithm base (default 10). Must be greater than 1.

Type:

float

base: float = 10#
sample(key)[source]#
Parameters:

key (PRNGKey)

Return type:

Array

__init__(lower_bound, upper_bound, base=10)#
Parameters:
Return type:

None

class hyperoptax.spaces.QLinearSpace(lower_bound, upper_bound, datatype=<class 'jax.numpy.int32'>)[source]#

Quantized (integer) variant of LinearSpace.

Samples uniformly from [lower_bound, upper_bound] and rounds to the nearest integer. Use this for discrete integer hyperparameters with a uniform prior (e.g. number of layers, batch size).

Parameters:
lower_bound#

Inclusive lower bound.

Type:

float

upper_bound#

Exclusive upper bound.

Type:

float

datatype#

Integer dtype used after rounding (default jnp.int32).

Type:

type

datatype#

alias of int32

transform(value)[source]#
Return type:

Array

__init__(lower_bound, upper_bound, datatype=<class 'jax.numpy.int32'>)#
Parameters:
Return type:

None

class hyperoptax.spaces.QLogSpace(lower_bound, upper_bound, base=10, datatype=<class 'jax.numpy.int32'>)[source]#

Quantized (integer) variant of LogSpace.

Samples in log space and rounds to the nearest integer. Use this for integer hyperparameters whose scale spans orders of magnitude (e.g. number of hidden units, number of warmup steps).

Parameters:
datatype#

alias of int32

transform(value)[source]#
Return type:

Array

__init__(lower_bound, upper_bound, base=10, datatype=<class 'jax.numpy.int32'>)#
Parameters:
Return type:

None