NeckBase<T>
Base Classes · AiDotNet.ComputerVision.Detection.Necks
Base class for neck modules that perform multi-scale feature fusion.
Inheritance: ModelBase<T, Tensor<T>, Tensor<T>> → NeckBase<T>
Known derived types: BiFPN<T>, FPN<T>, PANet<T>, YOLOv9Neck<T>, YoloPanNeckBase<T>
For Beginners
The “neck” sits between the backbone and the detection head. It takes multi-scale features from the backbone and fuses them together so that each feature level contains information from both higher and lower resolutions. This helps detect objects of various sizes more accurately.
How It Works
Common neck architectures:
- FPN (Feature Pyramid Network): Top-down feature fusion
- PANet (Path Aggregation Network): Top-down + bottom-up paths
- BiFPN (Bidirectional FPN): Weighted bidirectional fusion
Properties
| Property | Summary |
|---|---|
ILossFunction<T> DefaultLossFunction { get; } |
|
IReadOnlyList<int> LevelChannels { get; } |
Channels of each output level, finest first. |
int NumLevels { get; } |
Number of feature levels output by the neck. |
int OutputChannels { get; } |
Number of output channels for all feature levels. |
string Name { get; } |
Name of this neck architecture. |
Methods
| Method | Summary |
|---|---|
IFullModel<T, Tensor<T>, Tensor<T>> WithParameters(Vector<T> parameters) |
See GetParameters. |
List<Tensor<T>> Forward(List<Tensor<T>> features) |
Performs multi-scale feature fusion. |
Tensor<T> Predict(Tensor<T> input) |
Single-tensor Predict is not a meaningful operation for a detection neck: concrete necks (FPN, PANet, BiFPN) operate on the full backbone feature pyramid (a List with one tensor per level) and would fail their own feature-count validati… |
long GetParameterCount() |
Gets the total number of parameters in the neck. |
void ReadParameters(BinaryReader reader) |
Reads parameters from a binary reader for deserialization. |
void SetTrainingMode(bool training) |
Sets whether the neck is in training mode. |
void Train(Tensor<T> input, Tensor<T> expectedOutput) |
Detection necks (FPN, PANet, BiFPN) are not standalone-trainable: they are trained as part of a parent detector that orchestrates the joint backbone+neck+head pass. |
void WriteParameters(BinaryWriter writer) |
Writes all parameters to a binary writer for serialization. |