pub struct GradAccumulator {
pub grad_weights: Vec<f64>,
pub grad_biases: Vec<f64>,
pub count: usize,
}Expand description
Accumulates gradients from multiple backward passes for mini-batch training.
Fields§
§grad_weights: Vec<f64>Accumulated weight gradients.
grad_biases: Vec<f64>Accumulated bias gradients.
count: usizeNumber of samples accumulated.
Implementations§
Source§impl GradAccumulator
impl GradAccumulator
Sourcepub fn new(n_weights: usize, n_biases: usize) -> Self
pub fn new(n_weights: usize, n_biases: usize) -> Self
Create a new accumulator sized for n_weights weights and n_biases biases.
Sourcepub fn accumulate(&mut self, gw: &[f64], gb: &[f64])
pub fn accumulate(&mut self, gw: &[f64], gb: &[f64])
Add a set of gradients (accumulate without dividing).
Trait Implementations§
Source§impl Clone for GradAccumulator
impl Clone for GradAccumulator
Source§fn clone(&self) -> GradAccumulator
fn clone(&self) -> GradAccumulator
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 GradAccumulator
impl RefUnwindSafe for GradAccumulator
impl Send for GradAccumulator
impl Sync for GradAccumulator
impl Unpin for GradAccumulator
impl UnsafeUnpin for GradAccumulator
impl UnwindSafe for GradAccumulator
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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