Main Content

Max Pooling 2D Layer

2-D max pooling layer

Since R2024b

  • Max Pooling 2D Layer block

Libraries:
Deep Learning Toolbox / Deep Learning Layers / Pooling Layers

Description

The Max Pooling 2D Layer block performs downsampling by dividing the input into rectangular pooling regions, then computing the maximum of each region. This block accepts 2-D image data in the SSC format (three dimensions corresponding to two spatial dimensions and one channel dimension, in that order) and pools over the spatial dimensions.

The exportNetworkToSimulink function generates this block to represent a maxPooling2dLayer object.

Limitations

  • The Layer parameter has limited support for the 'manual' padding mode. It is recommended to use an maxPooling2dLayer object that has the PaddingMode property set to 'same'.

Ports

Input

expand all

Input data to downsample. The data must have three dimensions corresponding to two spatial dimensions and one channel dimension, in that order.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixed point

Output

expand all

The result of downsampling the input data. The output data has three dimensions corresponding to two spatial dimensions and one channel dimension, in that order.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixed point

Parameters

expand all

To edit block parameters interactively, use the Property Inspector. From the Simulink® Toolstrip, on the Simulation tab, in the Prepare gallery, select Property Inspector.

Main

Specify the name of a workspace variable that contains a maxPooling2dLayer object from a trained network. The Max Pooling 2D Layer block configures itself by using the properties of the object.

Programmatic Use

Block Parameter: Layer
Type: workspace variable
Values: maxPooling2dLayer object
Default: 'layer'

Data format for the input data. The options use the same notation as the fmt argument of the dlarray object, except layer blocks do not support the Batch (B) dimension and instead assume an observation number of 1.

Programmatic Use

Block Parameter: DataFormat
Type: character vector
Values: 'SSC'
Default: 'SSC'

Data Types

Lower value of the output range that the software checks.

The software uses the minimum to perform:

Tips

Output minimum does not saturate or clip the actual output signal. Use the Saturation (Simulink) block instead.

Programmatic Use

To set the block parameter value programmatically, use the set_param (Simulink) function.

Parameter: OutMin
Values: '[]' (default) | scalar in quotes

Upper value of the output range that the software checks.

The software uses the maximum value to perform:

Tips

Output maximum does not saturate or clip the actual output signal. Use the Saturation (Simulink) block instead.

Programmatic Use

To set the block parameter value programmatically, use the set_param (Simulink) function.

Parameter: OutMax
Values: '[]' (default) | scalar in quotes

Choose the data type for the output. The type can be inherited, specified directly, or expressed as a data type object such as Simulink.NumericType. When you choose Inherit: Inherit via internal rule, Simulink chooses a data type to balance numerical accuracy, performance, and generated code size, while taking into account the properties of the embedded target hardware.

Programmatic Use

To set the block parameter value programmatically, use the set_param (Simulink) function.

Parameter: OutDataTypeStr
Values: 'Inherit: Inherit via internal rule' (default) | | 'Inherit: Inherit via back propagation' | 'Inherit: Same as first input' | <data type expression>

Select this parameter to prevent the fixed-point tools from overriding the Output data type you specify on the block. For more information, see Use Lock Output Data Type Setting (Fixed-Point Designer).

Programmatic Use

To set the block parameter value programmatically, use the set_param (Simulink) function.

Parameter: LockScale
Values: 'off' (default) | 'on'

Specify the rounding mode for fixed-point operations. For more information, see Rounding Modes (Fixed-Point Designer).

Block parameters always round to the nearest representable value. To control the rounding of a block parameter, enter an expression using a MATLAB® rounding function into the mask field.

Programmatic Use

To set the block parameter value programmatically, use the set_param (Simulink) function.

Parameter: RndMeth
Values: 'Floor' (default) | 'Ceiling' | 'Convergent' | 'Nearest' | 'Round' | 'Simplest' | 'Zero'

Specify whether overflows saturate or wrap.

  • on — Overflows saturate to either the minimum or maximum value that the data type can represent.

  • off — Overflows wrap to the appropriate value that the data type can represent.

For example, the maximum value that the signed 8-bit integer int8 can represent is 127. Any block operation result greater than this maximum value causes overflow of the 8-bit integer.

  • With this parameter selected, the block output saturates at 127. Similarly, the block output saturates at a minimum output value of -128.

  • With this parameter cleared, the software interprets the overflow-causing value as int8, which can produce an unintended result. For example, a block result of 130 (binary 1000 0010) expressed as int8 is -126.

Tips

  • Consider selecting this parameter when your model has a possible overflow and you want explicit saturation protection in the generated code.

  • Consider clearing this parameter when you want to optimize efficiency of your generated code. Clearing this parameter also helps you to avoid overspecifying how a block handles out-of-range signals. For more information, see Troubleshoot Signal Range Errors (Simulink).

  • When you select this parameter, saturation applies to every internal operation on the block, not just the output or result.

  • In general, the code generation process can detect when overflow is not possible. In this case, the code generator does not produce saturation code.

Programmatic Use

To set the block parameter value programmatically, use the set_param (Simulink) function.

Parameter: SaturateOnIntegerOverflow
Values: 'off' (default) | 'on'

Execution

Specify the discrete interval between sample time hits or specify another type of sample time, such as continuous (0) or inherited (-1). For more options, see Types of Sample Time (Simulink).

By default, the block inherits its sample time based upon the context of the block within the model.

Programmatic Use

Block Parameter: SampleTime
Type: character vector
Values: scalar
Default: '-1'

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2024b