Skip to main content

Regularizer

Trait Regularizer 

Source
pub trait Regularizer {
    // Required methods
    fn compute_penalty(
        &self,
        parameters: &HashMap<String, Array<f64, Ix2>>,
    ) -> TrainResult<f64>;
    fn compute_gradient(
        &self,
        parameters: &HashMap<String, Array<f64, Ix2>>,
    ) -> TrainResult<HashMap<String, Array<f64, Ix2>>>;
}
Expand description

Trait for regularization strategies.

Required Methods§

Source

fn compute_penalty( &self, parameters: &HashMap<String, Array<f64, Ix2>>, ) -> TrainResult<f64>

Compute the regularization penalty for given parameters.

§Arguments
  • parameters - Model parameters to regularize
§Returns

The regularization penalty value

Source

fn compute_gradient( &self, parameters: &HashMap<String, Array<f64, Ix2>>, ) -> TrainResult<HashMap<String, Array<f64, Ix2>>>

Compute the gradient of the regularization penalty.

§Arguments
  • parameters - Model parameters
§Returns

Gradients of the regularization penalty for each parameter

Implementations on Foreign Types§

Source§

impl Regularizer for Box<dyn RegularizerClone>

Implementors§