RelationNetworkModel<T, TInput, TOutput>
Models & Types · AiDotNet.MetaLearning.Models
Relation Network model for few-shot classification.
Implements: IModel<TInput, TOutput, ModelMetadata<T>>
For Beginners
After the Relation Network sees the support examples (the few labeled examples for each class), this model remembers them and uses them to classify new query examples. It does this by computing how “related” the query is to each class.
How It Works
The adapted state of a Relation Network for one task: its own copy of the embedding module, the support set’s
embeddings and labels, and the learned comparison. Predict returns each example’s relation score
with every class, [rows, NumClasses], for Tensor and Matrix outputs - a class with no support example
scores zero - and the class with the highest score for a Vector output.
Constructors
| Constructor | Summary |
|---|---|
RelationNetworkModel(IFullModel<T, TInput, TOutput> featureEncoder, RelationModule<T> relationModule, TInput supportInputs, TOutput supportOutputs, RelationNetworkOptions<T, TInput, TOutput> options) |
Initializes a new instance of the RelationNetworkModel around one relation module. |
Properties
| Property | Summary |
|---|---|
ModelMetadata<T> Metadata { get; } |
Methods
| Method | Summary |
|---|---|
ModelMetadata<T> GetModelMetadata() |
|
TOutput Predict(TInput input) |
|
Vector<T> GetParameters() |
|
void Train(TInput inputs, TOutput targets) |
|
void UpdateParameters(Vector<T> parameters) |