Layer

Trait Layer 

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

Trait for neural network layers.

Required Methods§

Source

fn layer_type(&self) -> &str

Forward pass through the layer. Get the layer type name for serialization.

Source

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

Source

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

Get the layer’s parameters.

Source

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

Get mutable references to the layer’s parameters.

Source

fn update_parameter( &mut self, name: &str, value: Box<dyn ArrayProtocol>, ) -> Result<(), OperationError>

Update a specific parameter by name

Source

fn parameter_names(&self) -> Vec<String>

Get parameter names

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.

Implementors§