pub struct MixupLoss {
pub alpha: f64,
pub base_loss: Box<dyn Loss>,
}Expand description
Mixup data augmentation that mixes training examples and their labels.
Based on “mixup: Beyond Empirical Risk Minimization” (Zhang et al., 2018).
Fields§
§alpha: f64Alpha parameter for Beta distribution (typically 1.0).
base_loss: Box<dyn Loss>Base loss function.
Implementations§
Source§impl MixupLoss
impl MixupLoss
Sourcepub fn new(alpha: f64, base_loss: Box<dyn Loss>) -> TrainResult<Self>
pub fn new(alpha: f64, base_loss: Box<dyn Loss>) -> TrainResult<Self>
Create a new Mixup loss.
§Arguments
alpha- Beta distribution parameter (higher = more mixing)base_loss- Underlying loss function
Sourcepub fn compute_mixup(
&self,
predictions: &ArrayView<'_, f64, Ix2>,
mixed_targets: &ArrayView<'_, f64, Ix2>,
) -> TrainResult<f64>
pub fn compute_mixup( &self, predictions: &ArrayView<'_, f64, Ix2>, mixed_targets: &ArrayView<'_, f64, Ix2>, ) -> TrainResult<f64>
Compute mixup loss.
Note: In practice, mixup is applied during data loading, not in the loss function. This implementation assumes pre-mixed inputs and targets.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MixupLoss
impl !RefUnwindSafe for MixupLoss
impl !Send for MixupLoss
impl !Sync for MixupLoss
impl Unpin for MixupLoss
impl !UnwindSafe for MixupLoss
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