represents a pooling net layer using kernels of size sz.


represents a layer performing one-dimensional pooling with kernels of size w.


represents a layer performing two-dimensional pooling with kernels of size h×w.


represents a layer performing three-dimensional pooling with kernels of size h×w×d.


represents a layer that uses stride as the step size between kernel applications.


includes options for other pooling methods, padding and other parameters.

Details and Options

  • PoolingLayer[n,] represents a layer that, applied to an input tensor with c input channels and one or more spatial dimensions, performs c distinct pooling operations across the spatial dimensions to produce an output tensor with c channels.
  • PoolingLayer[n] is equivalent to PoolingLayer[n,1].
  • The following optional parameters can be included:
  • "Dimensionality"Automaticnumber of spatial dimensions of the pooling
    "Function"Maxaggregation function to use
    "Interleaving"Falsethe position of the channel dimension
    "PaddingSize"0amount of zero padding to apply to the input
  • With the setting "Interleaving"->False, the channel dimension is taken to be the first dimension of the input and output tensors.
  • With the setting "Interleaving"->True, the channel dimension is taken to be the last dimension of the input and output tensors.
  • The settings for kernel, stride, and "PaddingSize" can be of the following forms:
  • nuse the value n for all dimensions
    {,ni,}use the value ni for the i^(th) dimension
  • PoolingLayer[][input] explicitly computes the output from applying the layer.
  • PoolingLayer[][{input1,input2,}] explicitly computes outputs for each of the inputi.
  • PoolingLayer is typically used inside NetChain, NetGraph, etc.
  • NetExtract can be used to extract parameter values from a PoolingLayer object.
  • PoolingLayer exposes the following ports for use in NetGraph etc.:
  • "Input"a tensor of rank 2, 3 or 4
    "Output"a tensor of rank 2, 3 or 4
  • PoolingLayer can operate on tensors that contain "Varying" dimensions.
  • Possible explicit settings for the "Function" option include:
  • Maxthe maximum is used
    Meanthe mean value is used
    Totalthe sum of all values is used
  • When it cannot be inferred from other layers in a larger net, the option "Input"->{d1,,dn} can be used to fix the input dimensions of PoolingLayer.
  • Given an input tensor of dimensions d1××di×, the output tensor will be of dimensions ×××, where the channel dimension remains unchanged (i.e. d1=) and the sizes of spatial dimensions are transformed according to , where is the padding size, is the kernel size, and is the stride size for each dimension.


open allclose all

Basic Examples  (2)

Create a PoolingLayer with a kernel size of 5×5:

Click for copyable input

Create a one-dimensional PoolingLayer:

Click for copyable input

Apply the layer to an input matrix:

Click for copyable input

Scope  (4)

Options  (4)

Properties & Relations  (2)

See Also

ConvolutionLayer  BatchNormalizationLayer  SpatialTransformationLayer  AggregationLayer  NetChain  NetGraph  NetTrain


Introduced in 2016
| Updated in 2018