PoolingLayer<T>
Layers · AiDotNet.NeuralNetworks.Layers
Represents a layer that performs pooling operations on input tensors.
Inheritance: LayerBase<T> → PoolingLayer<T>
Implements: IShapeContract
For Beginners
This layer helps reduce the size of your data while keeping the important information.
Think of it like creating a thumbnail of an image:
- The pooling layer divides your input into small regions (e.g., 2×2 squares)
- For each region, it either:
- Takes the maximum value (max pooling): good for detecting features like edges
- Takes the average value (average pooling): good for preserving background information
- This creates a smaller output with fewer pixels but retains the important features
For example, using 2×2 max pooling on a 4×4 image would give you a 2×2 output, where each value is the maximum from its corresponding 2×2 region in the input.
Pooling helps make your neural network:
- More efficient (by reducing the amount of data)
- More robust (by being less sensitive to exact positions of features)
- Less prone to overfitting (by reducing the number of parameters)
How It Works
The PoolingLayer reduces the spatial dimensions (height and width) of input tensors by applying either max pooling or average pooling within local regions. This operation is commonly used in convolutional neural networks to reduce the spatial dimensions of feature maps, which helps to reduce computation, provide translation invariance, and control overfitting.
Constructors
| Constructor | Summary |
|---|---|
PoolingLayer(int poolSize, int stride, PoolingType type) |
Initializes a new instance of the PoolingLayer class with the specified dimensions and pooling parameters. |
Properties
| Property | Summary |
|---|---|
PoolingType Type { get; } |
Gets the type of pooling operation to perform. |
bool SupportsTraining { get; } |
Gets a value indicating whether this layer supports training. |
int PoolSize { get; } |
Gets the size of the pooling window. |
int Stride { get; } |
Gets the stride of the pooling operation. |
Methods
| Method | Summary |
|---|---|
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank) |
|
void ResetState() |
Resets the internal state of the pooling layer. |