pub struct CutMixAugmenter {
pub alpha: f64,
}Expand description
CutMix augmentation (ICCV 2019).
Instead of mixing pixels uniformly like Mixup, CutMix cuts a rectangular region from one image and pastes it to another. Labels are mixed proportionally to the area of the patch.
Reference: Yun et al. “CutMix: Regularization Strategy to Train Strong Classifiers with Localizable Features” (ICCV 2019)
Fields§
§alpha: f64Beta distribution parameter for sampling mixing ratio.
Implementations§
Source§impl CutMixAugmenter
impl CutMixAugmenter
Sourcepub fn new(alpha: f64) -> TrainResult<Self>
pub fn new(alpha: f64) -> TrainResult<Self>
Sourcepub fn augment_batch(
&self,
data: &ArrayView2<'_, f64>,
labels: &ArrayView2<'_, f64>,
rng: &mut StdRng,
) -> TrainResult<(Array2<f64>, Array2<f64>)>
pub fn augment_batch( &self, data: &ArrayView2<'_, f64>, labels: &ArrayView2<'_, f64>, rng: &mut StdRng, ) -> TrainResult<(Array2<f64>, Array2<f64>)>
Apply CutMix augmentation to a batch of data.
For 2D feature arrays, we treat the second dimension as a “spatial” dimension and cut rectangular regions along it.
§Arguments
data- Input data batch [N, features]labels- Corresponding labels [N, classes]rng- Random number generator
§Returns
Tuple of (augmented_data, augmented_labels)
Trait Implementations§
Source§impl Clone for CutMixAugmenter
impl Clone for CutMixAugmenter
Source§fn clone(&self) -> CutMixAugmenter
fn clone(&self) -> CutMixAugmenter
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 DataAugmenter for CutMixAugmenter
impl DataAugmenter for CutMixAugmenter
Source§fn augment(
&self,
data: &ArrayView2<'_, f64>,
_rng: &mut StdRng,
) -> TrainResult<Array2<f64>>
fn augment( &self, data: &ArrayView2<'_, f64>, _rng: &mut StdRng, ) -> TrainResult<Array2<f64>>
Augment the given data. Read more
Source§impl Debug for CutMixAugmenter
impl Debug for CutMixAugmenter
Auto Trait Implementations§
impl Freeze for CutMixAugmenter
impl RefUnwindSafe for CutMixAugmenter
impl Send for CutMixAugmenter
impl Sync for CutMixAugmenter
impl Unpin for CutMixAugmenter
impl UnwindSafe for CutMixAugmenter
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