pub struct Gradients { /* private fields */ }Expand description
A memory store mapping mathematical tensor nodes to their computed derivatives.
Implementations§
Source§impl Gradients
impl Gradients
Sourcepub fn get(&self, id: &TensorId) -> Option<&Buffer>
pub fn get(&self, id: &TensorId) -> Option<&Buffer>
Retrieves a reference to the computed gradient buffer for a specific Tensor.
Sourcepub fn remove(&mut self, id: &TensorId) -> Option<Buffer>
pub fn remove(&mut self, id: &TensorId) -> Option<Buffer>
Removes and takes ownership of a gradient buffer (useful for optimizers).
Sourcepub fn insert(&mut self, id: TensorId, new_grad: Buffer) -> EtensorResult<()>
pub fn insert(&mut self, id: TensorId, new_grad: Buffer) -> EtensorResult<()>
Pushes a computed derivative into the store.
The Calculus Accumulation Rule:
If a gradient already exists for this TensorId (meaning the tensor was used
multiple times in the forward graph), the new gradient is mathematically
added to the existing one.
Auto Trait Implementations§
impl Freeze for Gradients
impl RefUnwindSafe for Gradients
impl Send for Gradients
impl Sync for Gradients
impl Unpin for Gradients
impl UnsafeUnpin for Gradients
impl UnwindSafe for Gradients
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> 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