Class FPN<T>
- Namespace
- AiDotNet.ComputerVision.Detection.Necks
- Assembly
- AiDotNet.dll
Feature Pyramid Network (FPN) for multi-scale feature fusion.
public class FPN<T> : NeckBase<T>
Type Parameters
TThe numeric type used for calculations.
- Inheritance
-
NeckBase<T>FPN<T>
- Inherited Members
Remarks
For Beginners: FPN creates a feature pyramid by combining features from different backbone levels using a top-down pathway. High-resolution features from earlier layers are enriched with semantic information from deeper layers.
Key features: - Top-down pathway with lateral connections - 1x1 convolutions to match channel dimensions - Simple element-wise addition for fusion - Fast and memory efficient
Reference: Lin et al., "Feature Pyramid Networks for Object Detection", CVPR 2017
Constructors
FPN(NeckConfig)
Creates FPN from a configuration object.
public FPN(NeckConfig config)
Parameters
configNeckConfigNeck configuration.
FPN(int[], int)
Creates a new Feature Pyramid Network.
public FPN(int[] inputChannels, int outputChannels = 256)
Parameters
inputChannelsint[]Channel counts from backbone at each level.
outputChannelsintOutput channel count for all levels (default 256).
Properties
Name
Name of this neck architecture.
public override string Name { get; }
Property Value
NumLevels
Number of feature levels output by the neck.
public override int NumLevels { get; }
Property Value
OutputChannels
Number of output channels for all feature levels.
public override int OutputChannels { get; }
Property Value
Remarks
Necks typically project all feature levels to the same number of channels (e.g., 256) to simplify the detection head.
Methods
Forward(List<Tensor<T>>)
Performs multi-scale feature fusion.
public override List<Tensor<T>> Forward(List<Tensor<T>> features)
Parameters
featuresList<Tensor<T>>List of feature maps from the backbone, ordered from highest to lowest resolution.
Returns
- List<Tensor<T>>
Fused feature maps at multiple scales.
Remarks
For Beginners: This method takes the raw features from the backbone and combines them across scales. After fusion, each feature level "knows about" features from other scales, making detection more accurate.
GetParameterCount()
Gets the total number of parameters in the neck.
public override long GetParameterCount()
Returns
- long
Number of trainable parameters.
ReadParameters(BinaryReader)
Reads parameters from a binary reader for deserialization.
public override void ReadParameters(BinaryReader reader)
Parameters
readerBinaryReaderThe binary reader to read from.
WriteParameters(BinaryWriter)
Writes all parameters to a binary writer for serialization.
public override void WriteParameters(BinaryWriter writer)
Parameters
writerBinaryWriterThe binary writer to write to.