Skip to main content

OptNetLayer

Trait OptNetLayer 

Source
pub trait OptNetLayer {
    type ForwardResult;

    // Required methods
    fn forward(&self) -> OptimizeResult<Self::ForwardResult>;
    fn backward(
        &self,
        result: &Self::ForwardResult,
        dl_dx: &[f64],
    ) -> OptimizeResult<ImplicitGradient>;
}
Expand description

Trait for a differentiable optimization layer.

Implementations wrap a parametric optimization problem and expose forward/backward methods suitable for integration into gradient-based training pipelines.

Required Associated Types§

Source

type ForwardResult

The result type returned by the forward pass.

Required Methods§

Source

fn forward(&self) -> OptimizeResult<Self::ForwardResult>

Solve the optimization problem (forward pass).

Source

fn backward( &self, result: &Self::ForwardResult, dl_dx: &[f64], ) -> OptimizeResult<ImplicitGradient>

Compute parameter gradients (backward pass).

§Arguments
  • result – the result from a preceding forward() call.
  • dl_dx – upstream gradient of the loss w.r.t. the optimal solution.

Implementors§