pub struct GradientDict { /* private fields */ }
Expand description
Dictionary for storing parameter gradients
Implementations§
Source§impl GradientDict
impl GradientDict
Sourcepub fn insert(&mut self, name: String, gradient: Box<dyn ArrayProtocol>)
pub fn insert(&mut self, name: String, gradient: Box<dyn ArrayProtocol>)
Insert a gradient for a parameter
Sourcepub fn get(&self, name: &str) -> Option<&dyn ArrayProtocol>
pub fn get(&self, name: &str) -> Option<&dyn ArrayProtocol>
Get a gradient by parameter name
Sourcepub fn get_mut(&mut self, name: &str) -> Option<&mut Box<dyn ArrayProtocol>>
pub fn get_mut(&mut self, name: &str) -> Option<&mut Box<dyn ArrayProtocol>>
Get a mutable reference to a gradient by parameter name
Sourcepub fn iter(&self) -> impl Iterator<Item = (&String, &Box<dyn ArrayProtocol>)>
pub fn iter(&self) -> impl Iterator<Item = (&String, &Box<dyn ArrayProtocol>)>
Iterate over parameter names and gradients
Sourcepub fn merge(&mut self, other: GradientDict)
pub fn merge(&mut self, other: GradientDict)
Merge another gradient dictionary into this one
Sourcepub fn values(&self) -> impl Iterator<Item = &Box<dyn ArrayProtocol>>
pub fn values(&self) -> impl Iterator<Item = &Box<dyn ArrayProtocol>>
Get all gradients
Trait Implementations§
Source§impl Clone for GradientDict
impl Clone for GradientDict
Source§fn clone(&self) -> GradientDict
fn clone(&self) -> GradientDict
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for GradientDict
impl Debug for GradientDict
Auto Trait Implementations§
impl Freeze for GradientDict
impl !RefUnwindSafe for GradientDict
impl Send for GradientDict
impl Sync for GradientDict
impl Unpin for GradientDict
impl !UnwindSafe for GradientDict
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