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§
Sourcefn layer_type(&self) -> &str
fn layer_type(&self) -> &str
Forward pass through the layer. Get the layer type name for serialization.
fn forward( &self, inputs: &dyn ArrayProtocol, ) -> Result<Box<dyn ArrayProtocol>, OperationError>
Sourcefn parameters(&self) -> Vec<Box<dyn ArrayProtocol>>
fn parameters(&self) -> Vec<Box<dyn ArrayProtocol>>
Get the layer’s parameters.
Sourcefn parameters_mut(&mut self) -> Vec<&mut Box<dyn ArrayProtocol>>
fn parameters_mut(&mut self) -> Vec<&mut Box<dyn ArrayProtocol>>
Get mutable references to the layer’s parameters.
Sourcefn update_parameter(
&mut self,
name: &str,
value: Box<dyn ArrayProtocol>,
) -> Result<(), OperationError>
fn update_parameter( &mut self, name: &str, value: Box<dyn ArrayProtocol>, ) -> Result<(), OperationError>
Update a specific parameter by name
Sourcefn parameter_names(&self) -> Vec<String>
fn parameter_names(&self) -> Vec<String>
Get parameter names
Sourcefn is_training(&self) -> bool
fn is_training(&self) -> bool
Check if the layer is in training mode.