SNAILAlgorithm<T, TInput, TOutput>
Models & Types · AiDotNet.MetaLearning.Algorithms
Implementation of SNAIL (Simple Neural Attentive Meta-Learner) for few-shot learning.
Inheritance: ModelBase<T, TInput, TOutput> → MetaLearnerBase<T, TInput, TOutput> → SNAILAlgorithm<T, TInput, TOutput>
For Beginners
SNAIL treats few-shot learning as reading a story:
How it works:
- Take all support examples and their labels, arrange them in a sequence
- Append query examples (without labels) at the end
- Use temporal convolutions to capture local patterns (nearby examples)
- Use causal attention to capture global patterns (any previous example)
- The model predicts labels for query examples using what it “remembers”
Analogy: Imagine reading a detective novel:
- Support examples are like clues scattered through the story
- Temporal convolutions help you remember recent clues (short-term memory)
- Causal attention lets you recall any clue from the entire story (long-term memory)
- At the end (query), you must solve the mystery using all clues gathered
Key insight: By treating few-shot learning as sequence modeling, SNAIL can leverage powerful sequence architectures (temporal convolutions + attention) that have been very successful in NLP and speech recognition.
Architecture:
- Temporal Convolution (TC) blocks: Dilated causal convolutions that aggregate local info
- Causal Attention blocks: Attend to any previous position in the sequence
- Stacked TC + Attention blocks form the full SNAIL architecture
How It Works
SNAIL combines temporal convolutions with causal attention to process few-shot learning as a sequence modeling problem. Support examples (with labels) are fed sequentially, then query examples are fed to produce predictions. The model learns which examples to remember and attend to.
Algorithm - SNAIL:
Reference: Mishra, N., Rohaninejad, M., Chen, X., & Abbeel, P. (2018). A Simple Neural Attentive Learner. ICLR 2018.
Constructors
| Constructor | Summary |
|---|---|
SNAILAlgorithm(SNAILOptions<T, TInput, TOutput> options) |
Initializes a new SNAIL meta-learner. |
Properties
| Property | Summary |
|---|---|
MetaLearningAlgorithmType AlgorithmType { get; } |
Methods
| Method | Summary |
|---|---|
IModel<TInput, TOutput, ModelMetadata<T>> Adapt(IMetaLearningTask<T, TInput, TOutput> task) |
Adapts to a new task using SNAIL’s sequence processing. |
T MetaTrain(TaskBatch<T, TInput, TOutput> taskBatch) |
Performs one meta-training step for SNAIL. |