Table of Contents

Class BiFPN<T>

Namespace
AiDotNet.ComputerVision.Detection.Necks
Assembly
AiDotNet.dll

Bidirectional Feature Pyramid Network (BiFPN) with weighted feature fusion.

public class BiFPN<T> : NeckBase<T>

Type Parameters

T

The numeric type used for calculations.

Inheritance
BiFPN<T>
Inherited Members

Remarks

For Beginners: BiFPN improves upon FPN and PANet by using learnable weights for feature fusion. Instead of simply adding features, it learns how much each input feature should contribute to the fused output.

Key features: - Bidirectional (top-down + bottom-up) feature flow - Learnable weights for weighted feature fusion - Fast normalized fusion with softmax - Used in EfficientDet for state-of-the-art detection

Reference: Tan et al., "EfficientDet: Scalable and Efficient Object Detection", CVPR 2020

Constructors

BiFPN(NeckConfig)

Creates BiFPN from a configuration object.

public BiFPN(NeckConfig config)

Parameters

config NeckConfig

Neck configuration.

BiFPN(int[], int, int)

Creates a new Bidirectional Feature Pyramid Network.

public BiFPN(int[] inputChannels, int outputChannels = 256, int numRepeats = 3)

Parameters

inputChannels int[]

Channel counts from backbone at each level.

outputChannels int

Output channel count for all levels (default 256).

numRepeats int

Number of BiFPN repeat blocks (default 3).

Properties

Name

Name of this neck architecture.

public override string Name { get; }

Property Value

string

NumLevels

Number of feature levels output by the neck.

public override int NumLevels { get; }

Property Value

int

OutputChannels

Number of output channels for all feature levels.

public override int OutputChannels { get; }

Property Value

int

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

features List<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

reader BinaryReader

The binary reader to read from.

WriteParameters(BinaryWriter)

Writes all parameters to a binary writer for serialization.

public override void WriteParameters(BinaryWriter writer)

Parameters

writer BinaryWriter

The binary writer to write to.