pub trait TrustRegionOptimizer: BaseOptimizer {
    fn trust_region_backward_step(
        &mut self,
        loss_distance_fn: &mut dyn FnMut() -> (Tensor, Tensor),
        max_distance: f64,
        logger: &mut dyn StatsLogger
    ) -> Result<f64, OptimizerStepError>; }
Expand description

Optimizer that minimizes a loss function subject to a trust region constraint on each step.

Required Methods

Take an optimization step subject to a distance constraint

This function obtains gradients by backpropagating the result of loss_distance_fn, once for each loss and distance. It is not necessary for the caller to compute or zero out the existing gradients.

Args
  • loss_distance_fn - Function returning scalar loss and distance values.

    • Loss is minimized.
    • The non-negative distance value measures a deviation of the current parameter values from the initial parameters at the start of this step. It should equal zero at the start of the step.
  • max_distance - Upper bound on the distance value for this step.

  • logger - Logger for statistics and other information about the step.

Returns

The initial loss value on success.

Implementors