Skip to main content

Layer

Trait Layer 

Source
pub trait Layer<const IN: usize, const OUT: usize> {
    // Required methods
    fn forward(&self, input: &[Float; IN], output: &mut [Float; OUT]);
    fn backward(
        &mut self,
        input: &[Float; IN],
        output: &[Float; OUT],
        output_grad: &[Float; OUT],
        input_grad: &mut [Float; IN],
    );

    // Provided methods
    fn zero_grad(&mut self) { ... }
    fn apply_gradients(
        &mut self,
        _optimizer: &mut dyn Optimizer,
        _slot: &mut usize,
        _scale: Float,
    ) { ... }
}

Required Methods§

Source

fn forward(&self, input: &[Float; IN], output: &mut [Float; OUT])

Source

fn backward( &mut self, input: &[Float; IN], output: &[Float; OUT], output_grad: &[Float; OUT], input_grad: &mut [Float; IN], )

Provided Methods§

Source

fn zero_grad(&mut self)

Source

fn apply_gradients( &mut self, _optimizer: &mut dyn Optimizer, _slot: &mut usize, _scale: Float, )

Implementors§

Source§

impl<const IN: usize, const OUT: usize> Layer<IN, OUT> for DenseLayer<IN, OUT>

Source§

impl<const IW: usize, const IH: usize, const IC: usize, const FH: usize, const FW: usize, const OC: usize, const S: usize, const P: usize> Layer<{ IC * IH * IW }, { OC * conv_out_dim(IH, P, FH, S) * conv_out_dim(IW, P, FW, S) }> for Conv<IW, IH, IC, FH, FW, OC, S, P>
where [(); { _ }]:, (): ConvGeometryIsValid<IH, IW, FH, FW, S, P>,

Source§

impl<const N: usize> Layer<N, N> for Flatten<N>

Source§

impl<const N: usize> Layer<N, N> for ReLU<N>

Source§

impl<const N: usize> Layer<N, N> for Sigmoid<N>