GlobalPoolingLayer<T>
Layers · AiDotNet.NeuralNetworks.Layers
Represents a global pooling layer that reduces spatial dimensions to a single value per channel.
Inheritance: LayerBase<T> → GlobalPoolingLayer<T>
Implements: IShapeContract
For Beginners
A global pooling layer summarizes each feature map into a single value.
Imagine you have a set of 2D feature maps (like heat maps showing where different features appear):
- Global pooling looks at each entire feature map
- It creates a single number that represents that entire feature map
- This dramatically reduces the amount of data while preserving the most important information
For example, with 64 feature maps of size 7×7:
- Input: 7×7—64 (3,136 values)
- Output: 1×1—64 (64 values, one per feature map)
There are two main types of global pooling:
- Global Max Pooling: Takes the maximum value from each feature map
(useful for detecting if a feature appears anywhere in the input)
- Global Average Pooling: Takes the average of all values in each feature map
(useful for determining the overall presence of a feature)
Global pooling is often used as the final layer before classification, replacing large fully connected layers and reducing overfitting.
How It Works
A global pooling layer reduces the spatial dimensions (height and width) of the input feature maps to a single value per channel. This is achieved by applying a pooling operation (such as max or average) across the entire spatial extent of each channel. Global pooling is often used at the end of convolutional neural networks to reduce the spatial dimensions before connecting to fully connected layers, providing some translation invariance and reducing the number of parameters.
Constructors
| Constructor | Summary |
|---|---|
GlobalPoolingLayer(PoolingType poolingType, IActivationFunction<T> activationFunction) |
Initializes a new instance of the GlobalPoolingLayer class with a vector activation function. |
GlobalPoolingLayer(PoolingType poolingType, IVectorActivationFunction<T> vectorActivationFunction) |
Initializes a new instance of the GlobalPoolingLayer class with a vector activation function. |
Properties
| Property | Summary |
|---|---|
bool SupportsGpuTraining { get; } |
|
bool SupportsTraining { get; } |
Gets a value indicating whether this layer supports training. |
Methods
| Method | Summary |
|---|---|
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank) |
|
void ResetState() |
Resets the internal state of the layer. |