Class DistillationStrategyFactory<T>
- Namespace
- AiDotNet.KnowledgeDistillation
- Assembly
- AiDotNet.dll
Factory for creating distillation strategies from enums and configurations.
public static class DistillationStrategyFactory<T>
Type Parameters
TThe numeric type for calculations.
- Inheritance
-
DistillationStrategyFactory<T>
- Inherited Members
Methods
Configure(DistillationStrategyType)
Creates a strategy with custom parameters using a fluent builder pattern.
public static DistillationStrategyFactory<T>.StrategyBuilder Configure(DistillationStrategyType strategyType)
Parameters
strategyTypeDistillationStrategyType
Returns
CreateStrategy(DistillationStrategyType, double, double, double?, double?, ContrastiveMode?, Vector<string>?, Vector<string>?, Vector<IDistillationStrategy<T>>?, Vector<double>?)
Creates a distillation strategy from the specified type and parameters.
public static IDistillationStrategy<T> CreateStrategy(DistillationStrategyType strategyType, double temperature = 3, double alpha = 0.3, double? featureWeight = null, double? attentionWeight = null, ContrastiveMode? contrastiveMode = null, Vector<string>? featureLayerPairs = null, Vector<string>? attentionLayers = null, Vector<IDistillationStrategy<T>>? strategies = null, Vector<double>? strategyWeights = null)
Parameters
strategyTypeDistillationStrategyTypeThe type of strategy to create.
temperaturedoubleSoftmax temperature (default 3.0).
alphadoubleWeight for hard loss vs soft loss (default 0.3).
featureWeightdouble?Weight for feature matching loss (for feature-based strategies).
attentionWeightdouble?Weight for attention matching loss (for attention-based strategies).
contrastiveModeContrastiveMode?Mode for contrastive loss (for contrastive strategies).
featureLayerPairsVector<string>Layer pairs for feature matching (for feature-based).
attentionLayersVector<string>Attention layers to match (for attention-based).
strategiesVector<IDistillationStrategy<T>>Vector of strategies to combine (for hybrid).
strategyWeightsVector<double>Weights for combined strategies (for hybrid).
Returns
- IDistillationStrategy<T>
A configured distillation strategy.