pub struct ClassWrapper<G: Gradients, M: ClassMarker> { /* private fields */ }
Expand description
A wrapper type for gradients which overrides the class reported via Gradients::grad_iter_mut_with_class.
Trait Implementations§
Source§impl<G: Clone + Gradients, M: Clone + ClassMarker> Clone for ClassWrapper<G, M>
impl<G: Clone + Gradients, M: Clone + ClassMarker> Clone for ClassWrapper<G, M>
Source§fn clone(&self) -> ClassWrapper<G, M>
fn clone(&self) -> ClassWrapper<G, M>
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<G: Gradients, M: ClassMarker> Gradients for ClassWrapper<G, M>
impl<G: Gradients, M: ClassMarker> Gradients for ClassWrapper<G, M>
type Concrete = <G as Gradients>::Concrete
Source§fn grad_iter(&self) -> impl Iterator<Item = &Self::Concrete>
fn grad_iter(&self) -> impl Iterator<Item = &Self::Concrete>
Returns an iterator over each parameter gradient.
Source§fn grad_iter_mut(&mut self) -> impl Iterator<Item = &mut Self::Concrete>
fn grad_iter_mut(&mut self) -> impl Iterator<Item = &mut Self::Concrete>
Returns a mutable iterator over each parameter gradient.
Source§fn grad_iter_mut_with_class(
&mut self,
) -> impl Iterator<Item = (&mut Self::Concrete, GradClass)>
fn grad_iter_mut_with_class( &mut self, ) -> impl Iterator<Item = (&mut Self::Concrete, GradClass)>
Returns a mutable iterator over each parameter gradient, yielding
both the parameter gradient and its GradClass.
Source§fn into_grads(self) -> impl Iterator<Item = Self::Concrete>
fn into_grads(self) -> impl Iterator<Item = Self::Concrete>
Consumes the object, returning an iterator of each parameter gradient.
Source§fn merge(&mut self, other: Self, weight: f32)
fn merge(&mut self, other: Self, weight: f32)
Merges the values from the given gradient into the current one, based on the given weight. Read more
fn add(&mut self, other: Self)
Source§fn cosine_similarity(&self, other: &Self) -> Option<f32>
fn cosine_similarity(&self, other: &Self) -> Option<f32>
Returns the cosine similarity between the two gradients.
Auto Trait Implementations§
impl<G, M> Freeze for ClassWrapper<G, M>
impl<G, M> RefUnwindSafe for ClassWrapper<G, M>where
G: RefUnwindSafe,
M: RefUnwindSafe,
impl<G, M> Send for ClassWrapper<G, M>
impl<G, M> Sync for ClassWrapper<G, M>
impl<G, M> Unpin for ClassWrapper<G, M>
impl<G, M> UnwindSafe for ClassWrapper<G, M>where
G: UnwindSafe,
M: UnwindSafe,
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