Pooling Layers
DL4J equivalents and API reference for Keras pooling layers — MaxPooling, AveragePooling, and GlobalPooling in 1D, 2D, and 3D variants.
Keras Pooling Layer Import
Pooling layer support is implemented in the layers/pooling package. All standard Keras pooling layers are supported.
Support Summary
MaxPooling1D
Subsampling1DLayer (MAX)
Yes
MaxPooling2D
SubsamplingLayer (MAX)
Yes
MaxPooling3D
Subsampling3DLayer (MAX)
Yes
AveragePooling1D
Subsampling1DLayer (AVG)
Yes
AveragePooling2D
SubsamplingLayer (AVG)
Yes
AveragePooling3D
Subsampling3DLayer (AVG)
Yes
GlobalMaxPooling1D
GlobalPoolingLayer (MAX)
Yes
GlobalMaxPooling2D
GlobalPoolingLayer (MAX)
Yes
GlobalMaxPooling3D
GlobalPoolingLayer (MAX)
Yes
GlobalAveragePooling1D
GlobalPoolingLayer (AVG)
Yes
GlobalAveragePooling2D
GlobalPoolingLayer (AVG)
Yes
GlobalAveragePooling3D
GlobalPoolingLayer (AVG)
Yes
KerasPooling1D
Imports a Keras 1D pooling layer (MaxPooling1D or AveragePooling1D) as a DL4J Subsampling1DLayer.
Constructor
Parameters:
layerConfig— dictionary containing the Keras layer configuration
getSubsampling1DLayer
Returns the DL4J Subsampling1DLayer. The pooling type (MAX or AVG) is inferred from the Keras class name.
getOutputType
KerasPooling2D
Imports a Keras 2D pooling layer (MaxPooling2D or AveragePooling2D) as a DL4J SubsamplingLayer.
Constructor
getSubsampling2DLayer
Returns the DL4J SubsamplingLayer.
getOutputType
KerasPooling3D
Imports a Keras 3D pooling layer (MaxPooling3D or AveragePooling3D) as a DL4J Subsampling3DLayer.
Constructor
getSubsampling3DLayer
KerasGlobalPooling
Imports any Keras global pooling layer (GlobalMaxPooling1D/2D/3D, GlobalAveragePooling1D/2D/3D) as a DL4J GlobalPoolingLayer.
Constructor
getGlobalPoolingLayer
Returns the DL4J GlobalPoolingLayer. Pooling type and dimensionality are inferred from the Keras class name.
getInputPreprocessor
Returns the appropriate InputPreProcessor when the global pooling layer follows a layer with a different output format (e.g., following a convolutional layer).
getOutputType
KerasPoolingUtils
Utility class for pooling layer import.
mapPoolingType
Maps a Keras pooling class name (e.g., "MaxPooling2D") to the corresponding DL4J PoolingType enum value (PoolingType.MAX or PoolingType.AVG).
Parameters:
className— the Keras layer class name stringconf— theKerasLayerConfigurationinstance
Returns: DL4J PoolingType
Notes
All pooling layers use the
pool_size,strides, andpaddingparameters from the Keras configuration.The
paddingvalue"same"and"valid"are both supported and translated to the equivalent DL4J padding modes.Global pooling layers collapse the spatial dimensions entirely; DL4J's
GlobalPoolingLayerhandles all three dimensionalities via the same class, parameterized byPoolingDimensions.
Last updated
Was this helpful?