Skip to content

Commit 8beeed2

Browse files
committed
fix: add validation for LabelSmoothingFactor to ensure it's within [0, 1]
Added guard in KnowledgeDistillationOptions.Validate() to ensure LabelSmoothingFactor is within the valid range of [0, 1]. This prevents invalid configurations where LabelSmoothingFactor could be: - Negative (which would produce invalid smoothed labels) - Greater than 1 (which would produce invalid probability distributions) The check is placed alongside other weight/bound validations (Alpha, FeatureWeight, AttentionWeight, EMADecay) for consistency. Throws ArgumentException with clear message and nameof(LabelSmoothingFactor) for proper error reporting.
1 parent bb72f8b commit 8beeed2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/Models/Options/KnowledgeDistillationOptions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,8 @@ public void Validate()
393393
throw new ArgumentException("AttentionWeight must be between 0 and 1", nameof(AttentionWeight));
394394
if (EMADecay < 0 || EMADecay > 1)
395395
throw new ArgumentException("EMADecay must be between 0 and 1", nameof(EMADecay));
396+
if (LabelSmoothingFactor < 0 || LabelSmoothingFactor > 1)
397+
throw new ArgumentException("LabelSmoothingFactor must be between 0 and 1", nameof(LabelSmoothingFactor));
396398
if (SelfDistillationGenerations < 1)
397399
throw new ArgumentException("SelfDistillationGenerations must be at least 1", nameof(SelfDistillationGenerations));
398400

0 commit comments

Comments
 (0)