pub struct PolyLoss {
pub epsilon: f64,
pub poly_coeff: f64,
}Expand description
Poly Loss - Polynomial Expansion of Cross-Entropy Loss.
Paper: “PolyLoss: A Polynomial Expansion Perspective of Classification Loss Functions” (Leng et al., 2022) https://arxiv.org/abs/2204.12511
PolyLoss adds polynomial terms to cross-entropy to provide better gradient flow for well-classified examples. It helps with:
- Label noise robustness
- Improved generalization
- Better handling of class imbalance
The loss is defined as: L_poly = CE + ε₁(1 - p_t) + ε₂(1 - p_t)² + … + εⱼ(1 - p_t)^j
where p_t is the predicted probability of the target class, and εⱼ are polynomial coefficients. In practice, Poly-1 (j=1) is most commonly used.
Fields§
§epsilon: f64Epsilon for numerical stability
poly_coeff: f64Polynomial coefficient (typically between 0.5 and 2.0)
Implementations§
Trait Implementations§
Source§impl Loss for PolyLoss
impl Loss for PolyLoss
Source§fn compute(
&self,
predictions: &ArrayView<'_, f64, Ix2>,
targets: &ArrayView<'_, f64, Ix2>,
) -> TrainResult<f64>
fn compute( &self, predictions: &ArrayView<'_, f64, Ix2>, targets: &ArrayView<'_, f64, Ix2>, ) -> TrainResult<f64>
Compute loss value.
Auto Trait Implementations§
impl Freeze for PolyLoss
impl RefUnwindSafe for PolyLoss
impl Send for PolyLoss
impl Sync for PolyLoss
impl Unpin for PolyLoss
impl UnwindSafe for PolyLoss
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