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,
Descend
Gover the float plan againstctx; see the module docstring.initis the starting plan,(policy_len, action_dim)or(action_dim,)broadcast over the steps (default: the box midpoint).startsdescends from that many warm starts together (initfirst, then spread points of the box; orinitwith a leading(starts, policy_len, action_dim)axis) and returns the best final plan, with every start’s plan instart_plans, the best one’s index inpickand every start’s final score instart_scores.stepsandlrset the descent;optimizeris"adam"or"gradient". Adam’slris its first step, decayed linearly to zero (defaultDEFAULT_LR_FRACTIONof the box width per dimension); a plain gradient step’s size depends onG’s scale, so"gradient"takes an explicitlr, held fixed.use_boundpicks the point ofG’s interval that is descended. Adam’s normalisation is floored atsqrt(machine epsilon of the plan's dtype) · RMS(gradient), and the plan returned is the one with the lowest scoredGover 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 oftraceandgradient_trace, since a descent from a warm start can raiseGover its first steps before settling, andbest_stepnames the iterate returned.