DenseBlock<T>

Layers · AiDotNet.NeuralNetworks.Layers

Implements a Dense Block from the DenseNet architecture.

Inheritance: LayerBase<T> → DenseBlock<T>

Implements: IShapeContract

For Beginners

Dense connectivity means each layer can directly access features from all previous layers, promoting feature reuse and reducing the need for redundant feature learning.

Key benefits:

  • Strong gradient flow (helps with training very deep networks)
  • Feature reuse (each layer can use features from all previous layers)
  • Fewer parameters (layers can be narrow since they share features)

How It Works

A Dense Block is the core building block of DenseNet. It contains multiple layers where each layer receives feature maps from ALL preceding layers (dense connectivity). This creates strong gradient flow and feature reuse throughout the network.

Architecture of a Dense Block with n layers:

Where k is the growth rate (number of channels added per layer).

Constructors

Constructor Summary
DenseBlock(int numLayers, int growthRate, double bnMomentum) Initializes a new instance of the DenseBlock class.
DenseBlock(int numLayers, int growthRate, double bnMomentum, bool convolutionBias) Lazy ctor with the convolutions’ bias stated.

Properties

Property Summary
bool SupportsTraining { get; }
int GrowthRate { get; } Gets the growth rate (channels added per layer).
int NumLayers { get; } Gets the number of layers in this dense block.
int OutputChannels { get; } Gets the number of output channels (inputChannels + numLayers × growthRate).

Methods

Method Summary
IReadOnlyList<ILayer<T>> GetSubLayers()
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank)
void ClearGradients()
void ResetState() Resets the internal state of the block.
void UpdateParameters(T learningRate) Updates the parameters of all sub-layers.