pub struct DenseLayer {
pub weights: Vec<f32>,
pub biases: Vec<f32>,
pub in_features: usize,
pub out_features: usize,
pub activation: ActivationFn,
}Expand description
A single fully-connected (dense) layer with an activation function.
Weights are stored in row-major order: weights[out * in_features + in].
Fields§
§weights: Vec<f32>Weight matrix in row-major layout [out_features × in_features].
biases: Vec<f32>Bias vector of length out_features.
in_features: usizeNumber of input features.
out_features: usizeNumber of output features.
activation: ActivationFnActivation function applied after the affine transform.
Implementations§
Source§impl DenseLayer
impl DenseLayer
Sourcepub fn new(
in_features: usize,
out_features: usize,
activation: ActivationFn,
) -> Self
pub fn new( in_features: usize, out_features: usize, activation: ActivationFn, ) -> Self
Create a new layer with zero-initialised weights and biases.
Sourcepub fn set_weights(&mut self, w: &[f32])
pub fn set_weights(&mut self, w: &[f32])
Replace the weight matrix (must have length out_features * in_features).
§Panics
Panics if w.len() does not match.
Sourcepub fn set_biases(&mut self, b: &[f32])
pub fn set_biases(&mut self, b: &[f32])
Sourcepub fn parameter_count(&self) -> usize
pub fn parameter_count(&self) -> usize
Total number of trainable parameters (weights + biases).
Trait Implementations§
Source§impl Clone for DenseLayer
impl Clone for DenseLayer
Source§fn clone(&self) -> DenseLayer
fn clone(&self) -> DenseLayer
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 DenseLayer
impl RefUnwindSafe for DenseLayer
impl Send for DenseLayer
impl Sync for DenseLayer
impl Unpin for DenseLayer
impl UnsafeUnpin for DenseLayer
impl UnwindSafe for DenseLayer
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