AveragePooling2DLayer class

A 2D average pooling layer.

This layer downsamples an input feature map by taking the average value over a specified window (poolSize). It provides a smoother form of downsampling compared to MaxPooling2DLayer.

  • Input: A Tensor<Matrix> representing a single feature map of shape [height, width].
  • Output: A Tensor<Matrix> representing the downsampled feature map.

Example

SNetwork model = SNetwork([
  Conv2DLayer(16, 3, activation: ReLU()),
  AveragePooling2DLayer(poolSize: 2, stride: 2),
]);
Inheritance

Constructors

AveragePooling2DLayer({int poolSize = 2, int stride = 2})

Properties

hashCode int
The hash code for this object.
no setterinherited
inputHeight int
getter/setter pair
inputWidth int
getter/setter pair
name String
A user-friendly name for the layer (e.g., 'dense', 'lstm').
getter/setter pairoverride-getter
parameters List<Tensor>
A list of all trainable tensors (weights and biases) in the layer.
no setteroverride
poolSize int
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stride int
getter/setter pair

Methods

build(Tensor input) → void
Initializes the layer's parameters based on the shape of the first input.
override
call(Tensor input) Tensor
The public, callable interface for the layer.
inherited
forward(Tensor input) Tensor<Matrix>
The core logic of the layer's transformation.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited