pub struct KnowledgeDistillation { /* private fields */ }Expand description
Knowledge distillation trainer
Implementations§
Source§impl KnowledgeDistillation
impl KnowledgeDistillation
Sourcepub fn new(config: DistillationConfig) -> Self
pub fn new(config: DistillationConfig) -> Self
Create new knowledge distillation trainer
Sourcepub fn compute_loss(
&self,
student_logits: &Tensor,
teacher_logits: &Tensor,
targets: &Tensor,
) -> Result<Tensor, String>
pub fn compute_loss( &self, student_logits: &Tensor, teacher_logits: &Tensor, targets: &Tensor, ) -> Result<Tensor, String>
Compute distillation loss
Sourcepub fn store_teacher_output(&mut self, layer_name: String, output: Tensor)
pub fn store_teacher_output(&mut self, layer_name: String, output: Tensor)
Store teacher outputs
Sourcepub fn store_student_output(&mut self, layer_name: String, output: Tensor)
pub fn store_student_output(&mut self, layer_name: String, output: Tensor)
Store student outputs
Sourcepub fn clear_outputs(&mut self)
pub fn clear_outputs(&mut self)
Clear stored outputs
Sourcepub fn get_stats(&self) -> DistillationStats
pub fn get_stats(&self) -> DistillationStats
Get distillation statistics
Auto Trait Implementations§
impl Freeze for KnowledgeDistillation
impl !RefUnwindSafe for KnowledgeDistillation
impl Send for KnowledgeDistillation
impl Sync for KnowledgeDistillation
impl Unpin for KnowledgeDistillation
impl !UnwindSafe for KnowledgeDistillation
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