pub struct GradientProcessor<T: Float + Debug + Default + Clone + Sum + ScalarOperand + Send + Sync + 'static> { /* private fields */ }Expand description
Gradient processor for transformer optimizer
Implementations§
Source§impl<T: Float + Debug + Default + Clone + Sum + ScalarOperand + Send + Sync + 'static> GradientProcessor<T>
impl<T: Float + Debug + Default + Clone + Sum + ScalarOperand + Send + Sync + 'static> GradientProcessor<T>
Sourcepub fn new(strategy: GradientProcessingStrategy) -> Self
pub fn new(strategy: GradientProcessingStrategy) -> Self
Create new gradient processor
Sourcepub fn new_with_params(
strategy: GradientProcessingStrategy,
params: GradientProcessingParams<T>,
) -> Self
pub fn new_with_params( strategy: GradientProcessingStrategy, params: GradientProcessingParams<T>, ) -> Self
Create with custom parameters
Sourcepub fn process_gradients(&mut self, gradients: &Array1<T>) -> Result<Array1<T>>
pub fn process_gradients(&mut self, gradients: &Array1<T>) -> Result<Array1<T>>
Process gradients according to the selected strategy
Sourcepub fn statistics(&self) -> &GradientStatistics<T>
pub fn statistics(&self) -> &GradientStatistics<T>
Get gradient statistics
Sourcepub fn set_strategy(&mut self, strategy: GradientProcessingStrategy)
pub fn set_strategy(&mut self, strategy: GradientProcessingStrategy)
Update processing strategy
Sourcepub fn set_parameters(&mut self, params: GradientProcessingParams<T>)
pub fn set_parameters(&mut self, params: GradientProcessingParams<T>)
Update processing parameters
Trait Implementations§
Source§impl<T: Clone + Float + Debug + Default + Clone + Sum + ScalarOperand + Send + Sync + 'static> Clone for GradientProcessor<T>
impl<T: Clone + Float + Debug + Default + Clone + Sum + ScalarOperand + Send + Sync + 'static> Clone for GradientProcessor<T>
Source§fn clone(&self) -> GradientProcessor<T>
fn clone(&self) -> GradientProcessor<T>
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 moreAuto Trait Implementations§
impl<T> Freeze for GradientProcessor<T>where
T: Freeze,
impl<T> RefUnwindSafe for GradientProcessor<T>where
T: RefUnwindSafe,
impl<T> Send for GradientProcessor<T>
impl<T> Sync for GradientProcessor<T>
impl<T> Unpin for GradientProcessor<T>where
T: Unpin,
impl<T> UnsafeUnpin for GradientProcessor<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for GradientProcessor<T>where
T: UnwindSafe + RefUnwindSafe,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.