pub struct NeuralLayer {
pub weights: Vec<f64>,
pub biases: Vec<f64>,
pub n_in: usize,
pub n_out: usize,
}Expand description
A single fully-connected (dense) neural network layer.
Weights are stored in row-major order: weights[i * n_in + j] is the
weight from input j to output neuron i.
Fields§
§weights: Vec<f64>Flattened weight matrix of shape [n_out × n_in].
biases: Vec<f64>Bias vector of length n_out.
n_in: usizeNumber of input features.
n_out: usizeNumber of output neurons.
Implementations§
Source§impl NeuralLayer
impl NeuralLayer
Sourcepub fn new(n_in: usize, n_out: usize) -> Self
pub fn new(n_in: usize, n_out: usize) -> Self
Create a new layer with all weights and biases initialised to 0.1.
Sourcepub fn relu_forward(&self, input: &[f64]) -> Vec<f64>
pub fn relu_forward(&self, input: &[f64]) -> Vec<f64>
Forward pass with ReLU activation applied element-wise.
Sourcepub fn tanh_forward(&self, input: &[f64]) -> Vec<f64>
pub fn tanh_forward(&self, input: &[f64]) -> Vec<f64>
Forward pass with tanh activation applied element-wise.
Sourcepub fn output_size(&self) -> usize
pub fn output_size(&self) -> usize
Number of output neurons.
Sourcepub fn input_size(&self) -> usize
pub fn input_size(&self) -> usize
Number of input features.
Trait Implementations§
Source§impl Clone for NeuralLayer
impl Clone for NeuralLayer
Source§fn clone(&self) -> NeuralLayer
fn clone(&self) -> NeuralLayer
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for NeuralLayer
impl RefUnwindSafe for NeuralLayer
impl Send for NeuralLayer
impl Sync for NeuralLayer
impl Unpin for NeuralLayer
impl UnsafeUnpin for NeuralLayer
impl UnwindSafe for NeuralLayer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more