multistart_init#
- class braintools.optim.multistart_init(key, bounds, n_starts)#
Draw uniform starting points within box bounds.
- Parameters:
- Returns:
The structure of
boundswith every pair replaced by an array of shape(S, *broadcast(low, high).shape)drawn uniformly from[low, high); a Quantity in the unit oflowwhen the bounds carry one.- Return type:
- Raises:
ValueError – If
n_startsis not a positive integer.
See also
multistart_minimizeMinimise from the drawn starts.
Notes
n_startsfixes the output shape, so it must be a Pythonint. The function works underjax.jit(withn_startsstatic) andjax.vmapoverkey.Examples
>>> import jax >>> from braintools.optim import multistart_init >>> x0 = multistart_init(jax.random.PRNGKey(0), {'a': (0., 1.), 'b': (-2., 2.)}, 4) >>> x0['a'].shape, x0['b'].shape ((4,), (4,)) >>> bool(((x0['b'] >= -2.) & (x0['b'] < 2.)).all()) True