pub trait BackendOptimizer {
type Module;
// Required methods
fn clip_grad_norm(&mut self, max: f64);
fn step_module(&mut self, module: Self::Module) -> Self::Module;
fn learning_rate(&self) -> f64;
}Expand description
Burn-side optimizer interface used by PPO and DQN trainers.
Burn’s Optimizer<M, B> is move-through: every gradient step
consumes the module by value and returns the updated copy. This
trait exposes that single fundamental verb plus the
gradient-clipping configuration knob the trainer needs.
Required Associated Types§
Required Methods§
Sourcefn clip_grad_norm(&mut self, max: f64)
fn clip_grad_norm(&mut self, max: f64)
Stage the maximum global gradient L2-norm.
This only records the cap on the wrapper; the trainer bodies read it
back via BurnOptimizer::grad_clip_norm and apply the clip to the
gradient slice before their move-through inner_mut().step(...)
call (see the joint trainer’s per-policy step, issue #239). The
trait-level Self::step_module fallback does not itself clip.
Sourcefn step_module(&mut self, module: Self::Module) -> Self::Module
fn step_module(&mut self, module: Self::Module) -> Self::Module
Burn-style move-through update.
Consumes module, applies the optimizer’s staged gradient (with
any clipping configured by Self::clip_grad_norm), and returns
the updated module.
Sourcefn learning_rate(&self) -> f64
fn learning_rate(&self) -> f64
Construction-time learning rate. Exposed for diagnostics.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".