AdamOptimizer¶
- class madspace.AdamOptimizer(self: madspace._madspace_py.AdamOptimizer, function: madspace._madspace_py.Function, context: madspace._madspace_py.Context, learning_rate: SupportsFloat, schedule: madspace._madspace_py.AdamOptimizer.LRSchedule = <LRSchedule.none: 0>, step_count: SupportsInt = 0, beta1: SupportsFloat = 0.9, beta2: SupportsFloat = 0.999, eps: SupportsFloat = 1e-08, grad_clip_threshold: SupportsFloat = 0.0, weight_decay: SupportsFloat = 0.0)¶
Bases:
pybind11_objectAdam gradient-descent optimizer for a compute-graph loss function [1].
Wraps a loss
functioninto aRuntime, runs it forward and backward on each step, and applies the Adam update (beta1/beta2moment decay,epsfor numerical stability, optionalweight_decay) to itsrequires_gradContext globals.scheduleoptionally decays the learning rate overstep_countsteps;grad_clip_threshold, if non-zero, rescales the gradient norm before the update.References
[1] D. P. Kingma, J. Ba, “Adam: A method for stochastic optimization”, https://arxiv.org/abs/1412.6980
- Parameters:
function – The loss function to minimize.
context – Context whose
requires_gradglobals are trained.learning_rate – Initial (or, without
schedule, constant) learning rate.schedule – Learning-rate decay over training.
step_count – Total number of steps, for
schedule.beta1 – First-moment decay rate.
beta2 – Second-moment decay rate.
eps – Numerical-stability constant.
grad_clip_threshold – Maximum gradient norm;
0disables clipping.weight_decay – L2 weight-decay coefficient.
- class LRSchedule(*args, **kwargs)¶
Bases:
pybind11_objectLearning-rate decay applied over the course of training.
Members:
none
cosine
Overloaded function.
__init__(self: madspace._madspace_py.AdamOptimizer.LRSchedule, value: typing.SupportsInt) -> None
__init__(self: madspace._madspace_py.AdamOptimizer.LRSchedule, name: str) -> None
- cosine = <LRSchedule.cosine: 1>¶
- AdamOptimizer.LRSchedule.name -> str
- none = <LRSchedule.none: 0>¶
- property value¶
- context(self: madspace._madspace_py.AdamOptimizer) madspace._madspace_py.Context¶
The context being trained.
- cosine = <LRSchedule.cosine: 1>¶
- input_types(self: madspace._madspace_py.AdamOptimizer) list[madspace._madspace_py.Type]¶
Input types of the loss function.
- learning_rate(self: madspace._madspace_py.AdamOptimizer) float¶
The current, possibly
schedule-decayed, learning rate.
- none = <LRSchedule.none: 0>¶
- step(self: madspace._madspace_py.AdamOptimizer, inputs: collections.abc.Sequence[object]) list[madspace._madspace_py.Tensor]¶
Run one training step on
inputsand apply the Adam update; returnsfunction’s outputs.