IParameterSource<T>
Interfaces · AiDotNet.Interfaces
Anything that owns trainable parameters and can hand them out and take them back as a flat vector: a model, a sub-model, a layer, or an internal component such as an encoder or projector.
Known implementations: AutoIntBase<T>, CameraEmbedding<T>, CameraPoseEncoder<T>, ComponentAccessorParameterSource<T>, ComponentCollectionParameterSource<T>, ControlNetEncoder<T>, DelegatingParameterSource<T>, DoubleArrayParameterSource<T>, DoubleJaggedParameterSource<T>, DoubleScalarParameterSource<T>, FTTransformerBase<T>, GANDALFBase<T>, ILayer<T>, IMomentumEncoder<T>, IParameterizable<T, TInput, TOutput>, IProjectorHead<T>, IVariableLengthParameterSource<T>, ImageEncoder<T>, ImageProjector<T>, InterleavedCountParameterSource<T>, KeyedMatrixCollectionParameterSource<T, TKey>, KeyedScalarCollectionParameterSource<T, TKey>, KeyedTensorCollectionParameterSource<T, TKey>, KeyedVectorCollectionParameterSource<T, TKey>, MambularBase<T>, MaskHead<T>, MatrixCollectionParameterSource<T>, MatrixFieldParameterSource<T>, MatrixParameterSource<T>, MultiViewUNet<T>, NODEBase<T>, NeRFNetwork<T>, NestedKeyedScalarCollectionParameterSource<T, TOuterKey, TInnerKey>, PrototypeMaskHead<T>, QTableEntriesParameterSource<T>, QTableParameterSource<T>, RPN<T>, SAINTBase<T>, ScalarParameterSource<T>, TabDPTBase<T>, TabPFNBase<T>, TabRBase<T>, TabTransformerBase<T>, TensorCollectionParameterSource<T>, TensorFieldParameterSource<T>, TensorListParameterSource<T>, TimestepDependentLora<T>, ValueTableParameterSource<T>, VectorCollectionParameterSource<T>, VectorFieldWriteThroughSource<T>, VectorParameterSource<T>
For Beginners
implement this and a containing model can count, save and load your component’s numbers without knowing anything else about it.
How It Works
This is the minimal contract a parameter registry needs, and deliberately nothing more.
IParameterizable demands a good deal beyond it — most notably
WithParameters, which returns an IFullModel — so requiring it of a component would
force internal helpers like ControlNetEncoder or DiffWaveNetwork to pretend to be
standalone models. They already have these three members; they simply had no interface to say so.
The three are not independent. ParameterCount must equal the length of the vector
GetParameters returns, and SetParameters must accept exactly that
vector: callers pair them BY LENGTH, so an implementation whose count disagrees with its vector
causes a checkpoint to be restored into the wrong tensors, silently, leaving the model on its
initial weights. Derive one from the other rather than maintaining both.
Properties
| Property | Summary |
|---|---|
long ParameterCount { get; } |
How many parameters this owns. |
Methods
| Method | Summary |
|---|---|
Vector<T> GetParameters() |
All parameters as one flat vector, in a stable order. |
void SetParameters(Vector<T> parameters) |
Restores parameters from a vector produced by GetParameters. |