1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//! Knowledge distillation for model compression
//!
//! Knowledge distillation transfers knowledge from a large "teacher" model
//! to a smaller "student" model, maintaining accuracy while reducing size.
//!
//! # Overview
//!
//! Knowledge distillation uses soft probability distributions from a teacher model
//! to train a student model. The soft targets contain "dark knowledge" about class
//! relationships that hard labels cannot capture.
//!
//! # Example
//!
//! ```no_run
//! use oxigdal_ml::optimization::distillation::*;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Create configuration
//! let config = DistillationConfig::builder()
//! .loss(DistillationLoss::KLDivergence)
//! .temperature(3.0)
//! .alpha(0.7) // 70% distillation loss, 30% hard label loss
//! .epochs(100)
//! .learning_rate(0.001)
//! .batch_size(32)
//! .build();
//!
//! // Create trainer
//! let trainer = DistillationTrainer::new(config);
//!
//! // Prepare data
//! let teacher_outputs = vec![vec![1.0, 2.0, 0.5]];
//! let training_inputs = vec![vec![0.1, 0.2, 0.3]];
//! let training_labels = vec![1usize];
//! let initial_student_weights: Vec<f32> = vec![];
//!
//! // Train
//! let stats = trainer.train_with_teacher_outputs(
//! &teacher_outputs,
//! &training_inputs,
//! &training_labels,
//! &initial_student_weights,
//! )?;
//!
//! println!("Final accuracy: {:.2}%", stats.final_accuracy);
//! # Ok(())
//! # }
//! ```
// Re-export all public types
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;