pub struct GradientClipping<F: Float + Debug + ScalarOperand + Display> {
pub max_norm: F,
pub method: GradientClippingMethod,
pub log_stats: bool,
/* private fields */
}
Expand description
Gradient clipping callback
Fields§
§max_norm: F
Maximum norm for gradient clipping
method: GradientClippingMethod
Clipping method
log_stats: bool
Whether to log clipping statistics
Implementations§
Source§impl<F: Float + Debug + ScalarOperand + Display> GradientClipping<F>
impl<F: Float + Debug + ScalarOperand + Display> GradientClipping<F>
Sourcepub fn by_global_norm(max_norm: F, log_stats: bool) -> Self
pub fn by_global_norm(max_norm: F, log_stats: bool) -> Self
Create a new gradient clipping callback using global norm
Sourcepub fn by_value(max_value: F, log_stats: bool) -> Self
pub fn by_value(max_value: F, log_stats: bool) -> Self
Create a new gradient clipping callback using value clipping
Sourcepub fn was_clipping_applied(&self) -> bool
pub fn was_clipping_applied(&self) -> bool
Returns whether clipping was applied in the last step
Sourcepub fn get_clipping_ratio(&self) -> Option<F>
pub fn get_clipping_ratio(&self) -> Option<F>
Returns the clipping ratio from the last step (if global norm method was used)
Trait Implementations§
Source§impl<F: Float + Debug + ScalarOperand + Display> Callback<F> for GradientClipping<F>
impl<F: Float + Debug + ScalarOperand + Display> Callback<F> for GradientClipping<F>
Source§fn on_event(
&mut self,
timing: CallbackTiming,
context: &mut CallbackContext<'_, F>,
) -> Result<()>
fn on_event( &mut self, timing: CallbackTiming, context: &mut CallbackContext<'_, F>, ) -> Result<()>
Called during training at specific points
Auto Trait Implementations§
impl<F> Freeze for GradientClipping<F>where
F: Freeze,
impl<F> RefUnwindSafe for GradientClipping<F>where
F: RefUnwindSafe,
impl<F> Send for GradientClipping<F>where
F: Send,
impl<F> Sync for GradientClipping<F>where
F: Sync,
impl<F> Unpin for GradientClipping<F>where
F: Unpin,
impl<F> UnwindSafe for GradientClipping<F>where
F: 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> 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