hyperoptax.grid#
Classes
|
Exhaustive grid search over a discrete search space. |
- class hyperoptax.grid.GridSearchState(space, grid, grid_idx)[source]#
State for
GridSearch.- grid#
Array of shape
(n_total, n_params)containing all parameter combinations, pre-truncated to a multiple ofn_parallel.- Type:
- grid_idx#
Current position in
grid; incremented byn_parallelafter each call toupdate_state.- Type:
- class hyperoptax.grid.GridSearch(shuffle=False, n_parallel=1)[source]#
Exhaustive grid search over a discrete search space.
Iterates through every combination of the provided
DiscreteSpacevalues in order (or randomly ifshuffle=True). All spaces in the search space must beDiscreteSpace.- shuffle#
If
True, randomise the traversal order duringinit. Pass an explicitkeytoinitfor reproducibility.- Type:
- classmethod init(space, key=None, **kwargs)[source]#
Initialise the grid search.
- Parameters:
space – A pytree of
DiscreteSpaceobjects. All leaves must beDiscreteSpace; mixed spaces are not supported.key – Optional PRNG key used when
shuffle=True. Falls back toPRNGKey(0)whenNone.**kwargs – Forwarded to
GridSearchconstructor (e.g.n_parallel,shuffle).
- Returns:
(state, optimizer)tuple.
- get_next_params(state, key, params=None, results=None)[source]#
Return the next
n_parallelparameter combinations from the grid.- Parameters:
state (GridSearchState)
- Return type:
PyTree
- update_state(state, key, results, params=None)[source]#
Advance the grid index by
n_parallel.- Parameters:
state (GridSearchState)
- Return type: