pub trait NetLayer: Debug {
fn forward(
&self,
input: &Matrix<f64>,
params: MatrixSlice<'_, f64>
) -> LearningResult<Matrix<f64>>;
fn back_input(
&self,
out_grad: &Matrix<f64>,
input: &Matrix<f64>,
output: &Matrix<f64>,
params: MatrixSlice<'_, f64>
) -> Matrix<f64>;
fn back_params(
&self,
out_grad: &Matrix<f64>,
input: &Matrix<f64>,
output: &Matrix<f64>,
params: MatrixSlice<'_, f64>
) -> Matrix<f64>;
fn default_params(&self) -> Vec<f64>;
fn param_shape(&self) -> (usize, usize);
fn num_params(&self) -> usize { ... }
}
Expand description
Trait for neural net layers
Required Methods
sourcefn forward(
&self,
input: &Matrix<f64>,
params: MatrixSlice<'_, f64>
) -> LearningResult<Matrix<f64>>
fn forward(
&self,
input: &Matrix<f64>,
params: MatrixSlice<'_, f64>
) -> LearningResult<Matrix<f64>>
The result of propogating data forward through this layer
sourcefn back_input(
&self,
out_grad: &Matrix<f64>,
input: &Matrix<f64>,
output: &Matrix<f64>,
params: MatrixSlice<'_, f64>
) -> Matrix<f64>
fn back_input(
&self,
out_grad: &Matrix<f64>,
input: &Matrix<f64>,
output: &Matrix<f64>,
params: MatrixSlice<'_, f64>
) -> Matrix<f64>
The gradient of the output of this layer with respect to its input
sourcefn back_params(
&self,
out_grad: &Matrix<f64>,
input: &Matrix<f64>,
output: &Matrix<f64>,
params: MatrixSlice<'_, f64>
) -> Matrix<f64>
fn back_params(
&self,
out_grad: &Matrix<f64>,
input: &Matrix<f64>,
output: &Matrix<f64>,
params: MatrixSlice<'_, f64>
) -> Matrix<f64>
The gradient of the output of this layer with respect to its parameters
sourcefn default_params(&self) -> Vec<f64>
fn default_params(&self) -> Vec<f64>
The default value of the parameters of this layer before training
sourcefn param_shape(&self) -> (usize, usize)
fn param_shape(&self) -> (usize, usize)
The shape of the parameters used by this layer
Provided Methods
sourcefn num_params(&self) -> usize
fn num_params(&self) -> usize
The number of parameters used by this layer