pub fn map_into(self, f: impl Fn(ActivationT) -> ActivationT) -> Features {
        use Features::*;

        match self {
            Dense(activations) => Dense(activations.mapv_into(&f)),

            // Is the function sparsity preserving?
            Sparse(sa) => {
                let null_activation = f(0.0);

                if null_activation.abs() < 1e-5 {
                    let activations = sa.activations.into_iter().map(|(i, v)| (i, f(v))).collect();

                    Sparse(SparseActivations {
                        dim: sa.dim,
                        activations,
                    })
                } else {
                    let mut phi = Array1::from_elem(sa.dim, null_activation);

                    for (idx, act) in sa.activations.into_iter() {
                        phi[idx] = f(act);
                    }

                    Dense(phi)
                }
            }
        }
    }
/// Map all feature activations using an operation, `f`, and return.
Map all feature activations using an operation, `f`, and return.
Map all feature activations using an operation ` f ` and return .
pub fn map_into(self, f: impl Fn(ActivationT) -> ActivationT) -> Features {
        use Features::*;
        match self {
            Dense(activations) => Dense(activations.mapv_into(&f)),
            // Is the function sparsity preserving?
            Sparse(sa) => {
                let null_activation = f(0.0);
                if null_activation.abs() < 1e-5 {
                    let activations = sa.activations.into_iter().map(|(i, v)| (i, f(v))).collect();
                    Sparse(SparseActivations {
                        dim: sa.dim,
                        activations,
                    })
                } else {
                    let mut phi = Array1::from_elem(sa.dim, null_activation);
                    for (idx, act) in sa.activations.into_iter() {
                        phi[idx] = f(act);
                    }
                    Dense(phi)
                }
            }
        }
    }
pub fn map_into ( self , f : impl Fn ( ActivationT ) -> ActivationT ) -> Features { use Features :: * ; match self { Dense ( activations ) => Dense ( activations . mapv_into ( & f ) ) , // Is the function sparsity preserving? Sparse ( sa ) => { let null_activation = f ( 0.0 ) ; if null_activation . abs ( ) < 1e-5 { let activations = sa . activations . into_iter ( ) . map ( | ( i , v ) | ( i , f ( v ) ) ) . collect ( ) ; Sparse ( SparseActivations { dim : sa . dim , activations , } ) } else { let mut phi = Array1 :: from_elem ( sa . dim , null_activation ) ; for ( idx , act ) in sa . activations . into_iter ( ) { phi [ idx ] = f ( act ) ; } Dense ( phi ) } } } }
Map all feature activations using an operation, `f`, and return.
Map all feature activations using an operation ` f ` and return .
self
f
impl Fn(ActivationT) -> ActivationT
self
f
impl Fn(ActivationT) -> ActivationT