CNAPOptions<T, TInput, TOutput>
Options & Configuration · AiDotNet.MetaLearning.Options
Configuration options for the Conditional Neural Adaptive Processes (CNAP) algorithm.
Inheritance: ModelOptions → CNAPOptions<T, TInput, TOutput>
Implements: IMetaLearnerOptions<T>
For Beginners
CNAP learns to understand tasks from examples:
- It encodes examples (context points) into a task representation
- It uses this representation to generate task-specific fast weights
- The fast weights modify the base model to work well on that specific task
This is like having a teacher who can quickly understand what kind of problem you’re working on and adjust their teaching style accordingly.
How It Works
CNAP extends Neural Processes by conditioning on task-specific context points and learning to produce fast adaptation weights for each task. This enables effective few-shot learning through learned task representations.
Key Components:
- Encoder: Processes context points into task representations
- Adaptation Network: Generates task-specific fast weights from representations
- Base Model: The neural network that gets modified by fast weights
Constructors
| Constructor | Summary |
|---|---|
CNAPOptions(IFullModel<T, TInput, TOutput> metaModel) |
Initializes a new instance of the CNAPOptions class with the required meta-model. |
Properties
| Property | Summary |
|---|---|
FastWeightApplicationMode FastWeightMode { get; set; } |
Gets or sets how fast weights are applied to the model. |
IEpisodicDataLoader<T, TInput, TOutput> DataLoader { get; set; } |
Gets or sets the episodic data loader for sampling tasks. |
IFullModel<T, TInput, TOutput> MetaModel { get; set; } |
Gets or sets the meta-model to be trained. |
IGradientBasedOptimizer<T, TInput, TOutput> InnerOptimizer { get; set; } |
Must stay null: this algorithm takes no plain gradient inner step (it adapts without one, or by its own update rule), so a supplied optimizer is rejected when the learner is built. |
IGradientBasedOptimizer<T, TInput, TOutput> MetaOptimizer { get; set; } |
Optimizer for the meta-update. |
ILossFunction<T> LossFunction { get; set; } |
Loss function for meta-training; null uses the meta-model’s default loss. |
bool EnableCheckpointing { get; set; } |
Gets or sets whether to save checkpoints during training. |
bool NormalizeFastWeights { get; set; } |
Gets or sets whether to normalize fast weights. |
bool PredictUncertainty { get; set; } |
Gets or sets whether to predict uncertainty along with predictions. |
bool UseAttention { get; set; } |
Gets or sets whether to use attention for aggregating context points. |
bool UseFirstOrder { get; set; } |
Gets or sets whether to use first-order approximation. |
bool UseLayerNorm { get; set; } |
Gets or sets whether to use layer normalization in networks. |
double DropoutRate { get; set; } |
Gets or sets the dropout rate for regularization. |
double FastWeightRegularization { get; set; } |
Gets or sets the regularization weight for fast weights. |
double FastWeightScale { get; set; } |
Gets or sets the scale factor for fast weights. |
double InnerLearningRate { get; set; } |
Gets or sets the learning rate for the inner loop (task adaptation). |
double OuterLearningRate { get; set; } |
Gets or sets the learning rate for the outer loop (meta-update). |
double UncertaintyWeight { get; set; } |
Gets or sets the weight for uncertainty loss when predicting uncertainty. |
double? GradientClipThreshold { get; set; } |
Gets or sets the maximum gradient norm for gradient clipping. |
int AdaptationNetworkLayers { get; set; } |
Gets or sets the number of layers in the adaptation network. |
int AdaptationSteps { get; set; } |
Gets or sets the number of gradient steps to take during inner loop adaptation. |
int CheckpointFrequency { get; set; } |
Gets or sets how often to save checkpoints. |
int ContextSize { get; set; } |
Gets or sets the number of context points to use for encoding (support set size). |
int EncoderLayers { get; set; } |
Gets or sets the number of layers in the encoder network. |
int EvaluationFrequency { get; set; } |
Gets or sets how often to evaluate during meta-training. |
int EvaluationTasks { get; set; } |
Gets or sets the number of tasks to use for evaluation. |
int HiddenDimension { get; set; } |
Gets or sets the hidden dimension for the encoder and adaptation networks. |
int MetaBatchSize { get; set; } |
Gets or sets the number of tasks to sample per meta-training iteration. |
int NumAttentionHeads { get; set; } |
Gets or sets the number of attention heads when using attention. |
int NumMetaIterations { get; set; } |
Gets or sets the total number of meta-training iterations to perform. |
int RepresentationDimension { get; set; } |
Gets or sets the dimension of the task representation vector. |
int? RandomSeed { get; set; } |
Gets or sets the random seed for reproducibility. |
Methods
| Method | Summary |
|---|---|
IMetaLearnerOptions<T> Clone() |
Creates a deep copy of the CNAP options. |
bool IsValid() |
Validates that all CNAP configuration options are properly set. |