pub struct DistillationLoss {
pub temperature: f64,
pub alpha: f64,
pub hard_loss: Box<dyn Loss>,
}Expand description
Knowledge distillation loss that combines student predictions with teacher soft targets.
Based on “Distilling the Knowledge in a Neural Network” (Hinton et al., 2015).
Fields§
§temperature: f64Temperature for softening probabilities (higher = softer).
alpha: f64Weight for distillation loss (1 - alpha for hard target loss).
hard_loss: Box<dyn Loss>Base loss function for hard targets.
Implementations§
Source§impl DistillationLoss
impl DistillationLoss
Sourcepub fn new(
temperature: f64,
alpha: f64,
hard_loss: Box<dyn Loss>,
) -> TrainResult<Self>
pub fn new( temperature: f64, alpha: f64, hard_loss: Box<dyn Loss>, ) -> TrainResult<Self>
Create a new distillation loss.
§Arguments
temperature- Temperature for softening (typically 2.0-5.0)alpha- Weight for soft targets (typically 0.5-0.9)hard_loss- Loss function for hard targets
Auto Trait Implementations§
impl Freeze for DistillationLoss
impl !RefUnwindSafe for DistillationLoss
impl !Send for DistillationLoss
impl !Sync for DistillationLoss
impl Unpin for DistillationLoss
impl !UnwindSafe for DistillationLoss
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