pub struct FeatureDistillationLoss {
pub layer_weights: Vec<f64>,
pub p_norm: f64,
}Expand description
Feature-based distillation that matches intermediate layer representations.
Fields§
§layer_weights: Vec<f64>Weight for each feature layer.
p_norm: f64Distance metric (2.0 for L2, 1.0 for L1).
Implementations§
Source§impl FeatureDistillationLoss
impl FeatureDistillationLoss
Sourcepub fn new(layer_weights: Vec<f64>, p_norm: f64) -> TrainResult<Self>
pub fn new(layer_weights: Vec<f64>, p_norm: f64) -> TrainResult<Self>
Create a new feature distillation loss.
§Arguments
layer_weights- Weights for each intermediate layerp_norm- Norm to use for distance (1.0 or 2.0)
Sourcepub fn compute_feature_loss(
&self,
student_features: &[ArrayView<'_, f64, Ix2>],
teacher_features: &[ArrayView<'_, f64, Ix2>],
) -> TrainResult<f64>
pub fn compute_feature_loss( &self, student_features: &[ArrayView<'_, f64, Ix2>], teacher_features: &[ArrayView<'_, f64, Ix2>], ) -> TrainResult<f64>
Auto Trait Implementations§
impl Freeze for FeatureDistillationLoss
impl RefUnwindSafe for FeatureDistillationLoss
impl Send for FeatureDistillationLoss
impl Sync for FeatureDistillationLoss
impl Unpin for FeatureDistillationLoss
impl UnsafeUnpin for FeatureDistillationLoss
impl UnwindSafe for FeatureDistillationLoss
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