gradient_plan

Contents

gradient_plan#

hybrid_aif.planning.gradient_plan(
ctx,
*,
steps=200,
lr=None,
optimizer='adam',
init=None,
starts=1,
posterior='mode',
use_bound='midpoint',
metrics=True,
)[source]#

Descend G over the float plan against ctx; see the module docstring.

init is the starting plan, (policy_len, action_dim) or (action_dim,) broadcast over the steps (default: the box midpoint). starts descends from that many warm starts together (init first, then spread points of the box; or init with a leading (starts, policy_len, action_dim) axis) and returns the best final plan, with every start’s plan in start_plans, the best one’s index in pick and every start’s final score in start_scores. steps and lr set the descent; optimizer is "adam" or "gradient". Adam’s lr is its first step, decayed linearly to zero (default DEFAULT_LR_FRACTION of the box width per dimension); a plain gradient step’s size depends on G’s scale, so "gradient" takes an explicit lr, held fixed. use_bound picks the point of G’s interval that is descended. Adam’s normalisation is floored at sqrt(machine epsilon of the plan's dtype) · RMS(gradient), and the plan returned is the one with the lowest scored G over the warm start, the iterates and the final plan, unless the final plan’s score is not finite (see the module docstring). With several starts the best final score wins; a NaN score never wins, and when every start’s is NaN the first start’s is returned. Convergence is read from the last entries of trace and gradient_trace, since a descent from a warm start can raise G over its first steps before settling, and best_step names the iterate returned.