pub fn update_with<I>(
        &mut self,
        input: I,
        f: impl Fn(&Features, ndarray::Array1<f64>) -> ndarray::Array1<f64>,
    ) -> Result<()>
    where
        B: basis::Basis<I, Value = Features>,
        O: optim::Optimiser,
    {
        self.basis.project(input).and_then(|ref b| {
            let opt = &mut self.optimiser;
            let values = b.matmul(&self.weights);
            let errors = f(b, values).into_raw_vec();

            errors
                .into_iter()
                .zip(self.weights.columns_mut().into_iter())
                .fold(Ok(()), |acc, (e, mut c)| {
                    acc.and(opt.step_scaled(&mut c, b, e))
                })
        })
    }
/// Update the function approximator for a given `input`, deferring the
/// error computation to a closure provided by the user.
Update the function approximator for a given `input`, deferring the
error computation to a closure provided by the user.
Update the function approximator for a given ` input ` deferring the error computation to a closure provided by the user .
pub fn update_with<I>(
        &mut self,
        input: I,
        f: impl Fn(&Features, ndarray::Array1<f64>) -> ndarray::Array1<f64>,
    ) -> Result<()>
    where
        B: basis::Basis<I, Value = Features>,
        O: optim::Optimiser,
    {
        self.basis.project(input).and_then(|ref b| {
            let opt = &mut self.optimiser;
            let values = b.matmul(&self.weights);
            let errors = f(b, values).into_raw_vec();
            errors
                .into_iter()
                .zip(self.weights.columns_mut().into_iter())
                .fold(Ok(()), |acc, (e, mut c)| {
                    acc.and(opt.step_scaled(&mut c, b, e))
                })
        })
    }
pub fn update_with < I > ( & mut self , input : I , f : impl Fn ( & Features , ndarray :: Array1 < f64 > ) -> ndarray :: Array1 < f64 > , ) -> Result < ( ) > where B : basis :: Basis < I , Value = Features > , O : optim :: Optimiser , { self . basis . project ( input ) . and_then ( | ref b | { let opt = & mut self . optimiser ; let values = b . matmul ( & self . weights ) ; let errors = f ( b , values ) . into_raw_vec ( ) ; errors . into_iter ( ) . zip ( self . weights . columns_mut ( ) . into_iter ( ) ) . fold ( Ok ( ( ) ) , | acc , ( e , mut c ) | { acc . and ( opt . step_scaled ( & mut c , b , e ) ) } ) } ) }
Update the function approximator for a given `input`, deferring the
error computation to a closure provided by the user.
Update the function approximator for a given ` input ` deferring the error computation to a closure provided by the user .
&mut self
input
I
f
impl Fn(&Features, ndarray::Array1<f64>) -> ndarray::Array1<f64>
&mut self
input
I
f
impl Fn(&Features, ndarray::Array1<f64>) -> ndarray::Array1<f64>