Trait Layer

Source
pub trait Layer:
    Any
    + Send
    + Sync {
    // Required methods
    fn forward(
        &self,
        inputs: &dyn ArrayProtocol,
    ) -> Result<Box<dyn ArrayProtocol>, OperationError>;
    fn parameters(&self) -> Vec<Box<dyn ArrayProtocol>>;
    fn train(&mut self);
    fn eval(&mut self);
    fn is_training(&self) -> bool;
    fn name(&self) -> &str;
    fn as_any(&self) -> &dyn Any;
}
Expand description

Trait for neural network layers.

Required Methods§

Source

fn forward( &self, inputs: &dyn ArrayProtocol, ) -> Result<Box<dyn ArrayProtocol>, OperationError>

Forward pass through the layer.

Source

fn parameters(&self) -> Vec<Box<dyn ArrayProtocol>>

Get the layer’s parameters.

Source

fn train(&mut self)

Set the layer to training mode.

Source

fn eval(&mut self)

Set the layer to evaluation mode.

Source

fn is_training(&self) -> bool

Check if the layer is in training mode.

Source

fn name(&self) -> &str

Get the layer’s name.

Source

fn as_any(&self) -> &dyn Any

Downcast the layer to Any for type-specific operations.

Implementors§