Skip to content

create_dl_layer_poolingCreateDlLayerPoolingCreateDlLayerPoolingcreate_dl_layer_poolingT_create_dl_layer_poolingπŸ”—

Short descriptionπŸ”—

create_dl_layer_poolingCreateDlLayerPoolingCreateDlLayerPoolingcreate_dl_layer_poolingT_create_dl_layer_pooling β€” Create a pooling layer.

SignatureπŸ”—

create_dl_layer_pooling( dl_layer DLLayerInput, string LayerName, number KernelSize, number Stride, number Padding, number Mode, attribute.name GenParamName, attribute.value GenParamValue, out dl_layer DLLayerPooling )void CreateDlLayerPooling( const HTuple& DLLayerInput, const HTuple& LayerName, const HTuple& KernelSize, const HTuple& Stride, const HTuple& Padding, const HTuple& Mode, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* DLLayerPooling )static void HOperatorSet.CreateDlLayerPooling( HTuple DLLayerInput, HTuple layerName, HTuple kernelSize, HTuple stride, HTuple padding, HTuple mode, HTuple genParamName, HTuple genParamValue, out HTuple DLLayerPooling )def create_dl_layer_pooling( dllayer_input: HHandle, layer_name: str, kernel_size: Sequence[int], stride: Sequence[int], padding: MaybeSequence[Union[str, int]], mode: str, gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[Union[int, float, str]] ) -> HHandle

Herror T_create_dl_layer_pooling( const Htuple DLLayerInput, const Htuple LayerName, const Htuple KernelSize, const Htuple Stride, const Htuple Padding, const Htuple Mode, const Htuple GenParamName, const Htuple GenParamValue, Htuple* DLLayerPooling )

HDlLayer HDlLayer::CreateDlLayerPooling( const HString& LayerName, const HTuple& KernelSize, const HTuple& Stride, const HTuple& Padding, const HString& Mode, const HTuple& GenParamName, const HTuple& GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerPooling( const HString& LayerName, const HTuple& KernelSize, const HTuple& Stride, const HString& Padding, const HString& Mode, const HString& GenParamName, const HString& GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerPooling( const char* LayerName, const HTuple& KernelSize, const HTuple& Stride, const char* Padding, const char* Mode, const char* GenParamName, const char* GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerPooling( const wchar_t* LayerName, const HTuple& KernelSize, const HTuple& Stride, const wchar_t* Padding, const wchar_t* Mode, const wchar_t* GenParamName, const wchar_t* GenParamValue ) const (Windows only)

HDlLayer HDlLayer.CreateDlLayerPooling( string layerName, HTuple kernelSize, HTuple stride, HTuple padding, string mode, HTuple genParamName, HTuple genParamValue )

HDlLayer HDlLayer.CreateDlLayerPooling( string layerName, HTuple kernelSize, HTuple stride, string padding, string mode, string genParamName, string genParamValue )

DescriptionπŸ”—

The operator create_dl_layer_poolingCreateDlLayerPooling creates a pooling layer whose handle is returned in DLLayerPoolingDLLayerPoolingdllayer_pooling.

The parameter DLLayerInputDLLayerInputdllayer_input determines the feeding input layer and expects the layer handle as value.

The parameter LayerNamelayerNamelayer_name sets an individual layer name. Note that if creating a model using create_dl_modelCreateDlModel each layer of the created network must have a unique name.

The parameter KernelSizekernelSizekernel_size specifies the filter kernel in the dimensions width and height.

The parameter Stridestridestride specifies how the filter is shifted.

The values for KernelSizekernelSizekernel_size and Stridestridestride can be set as

  • a single value which is used for both dimensions

  • a tuple [width, height] and [column, row], respectively.

The parameter Paddingpaddingpadding determines the padding, thus how many pixels with value 0 are appended on the border of the processed input image. Supported values are:

  • 'half_kernel_size'"half_kernel_size": The number of appended pixels depends on the specifies KernelSizekernelSizekernel_size. More precisely, it is calculated as \(\lfloor\textrm{KernelSize} /2 \rfloor\), where for the padding on the left / right border the value of KernelSizekernelSizekernel_size in dimension width is regarded and for the padding on the upper / lower border the value of KernelSizekernelSizekernel_size in height.

  • 'implicit'"implicit": No pixels are appended on the left or on the top of the input image. The number of pixels appended on the right or lower border of the input image is \(\textrm{Stride}-(input\_dim-\textrm{KernelSize})\% \textrm{Stride}\), or zero if the kernel size is a divisor of the input dimension. \(input\_dim\) stands for the input width or height.

  • 'none'"none": No pixels are appended.

  • Number of pixels: Specify the number of pixels appended on each border. To do so, the following tuple lengths are supported:

    • Single number: Padding in all four directions left/right/top/bottom.

    • Two numbers: Padding in left/right and top/bottom: [l/r, t/b].

    • Four numbers: Padding on left, right, top, bottom side: [l,r,t,b].

      Restriction: 'runtime'"runtime" 'gpu'"gpu" does not support asymmetric padding, i.e., the padding values for the left and right side must be equal, as well as the padding values for the top and bottom side.

    Restriction: The integer padding values must be smaller than the value set for KernelSizekernelSizekernel_size in the corresponding dimension.

The output dimensions of the pooling layer are given by

\[\begin{eqnarray*} output\_dim = \left\lfloor\frac{input\_dim + padding\_begin + padding\_end - \textrm{KernelSize}} {\textrm{Stride}}\right\rfloor + 1 \end{eqnarray*}\]

Thereby we use the following values: \(output\_dim\): output width, \(input\_dim\): input width, \(padding\_begin\): number of pixels added to the left/top of the input image, and \(padding\_end\): number of pixels added to the right/bottom of the input image.

The parameter Modemodemode specifies the mode of the pooling operation. Supported modes are:

  • 'average'"average": The resulting pixel value is the average of all pixel values in the filter.

  • 'maximum'"maximum": The resulting pixel value is the maximum of all pixel values in the filter.

  • 'global_average'"global_average": Same as mode 'average'"average", but without the knowledge of the spatial dimensions of the input, it is possible to define the desired output dimensions via the parameter KernelSizekernelSizekernel_size. E.g., if the average over all pixel values of the input shall be returned, set the KernelSizekernelSizekernel_size to 11 and the output width and height is equal to 1. The internally used kernel size and stride are calculated as follows:

    • If KernelSizekernelSizekernel_size is a divisor of the input dimensions: The internally used kernel size and stride are both set to the value \(input\_dim/\textrm{KernelSize}\).

    • If KernelSizekernelSizekernel_size is not a divisor of the input dimension: The calculation of the internally used kernel size and stride depend on the generic parameter 'global_pooling_mode'"global_pooling_mode":

      • 'overlapping'"overlapping": The internally used \(stride\) is set to \(\lfloor input\_dim/\textrm{KernelSize}\rfloor\). The internally used kernel size is then computed as \(input\_dim - (\textrm{KernelSize} - 1) \cdot stride\). This leads to overlapping kernels but the whole input image is taken into account for the computation of the output.

      • 'non_overlapping'"non_overlapping": The internally used kernel size and stride are set to the same value \(\lfloor input\_dim/\textrm{KernelSize}\rfloor\). This leads to non-overlapping pooling kernels, but parts of the input image at the right or bottom border might not be considered when computing the output. In this mode, due to rounding the output size is not always equal to the size given by KernelSizekernelSizekernel_size.

      • 'adaptive'"adaptive": In this mode, for each pixel \((k,l)\) of the output, the size of the corresponding pooling area within the input is computed adaptively, where \(k\) are the row and \(l\) are the column indices of the output. The row indices of the pooling area for pixels of the \(k\)-th output row are given by \([\lfloor k \cdot input\_dim/\textrm{KernelSize}\rfloor, \lceil (k+1) \cdot input\_dim/\textrm{KernelSize}\rceil)\), where in this case the height of the KernelSizekernelSizekernel_size is used. The computation of the column coordinates is done analogously. This means that neighboring pooling areas can have a different size which can lead to a less efficient implementation. However, the pooling areas are only overlapping by one pixel which is generally less overlap than for 'global_pooling_mode'"global_pooling_mode" 'overlapping'"overlapping". The whole input image is taken into account for the computation of the output. For this mode, the parameter Paddingpaddingpadding must be set to 'none'"none".

    For this mode the parameter Stridestridestride is ignored and calculated internally as described above.

  • 'global_maximum'"global_maximum": Same as mode 'global_average'"global_average", but the maximum is calculated instead of the average.

For more information about the pooling layer see the β€œSolution Guide on Classification”.

The following generic parameters GenParamNamegenParamNamegen_param_name and the corresponding values GenParamValuegenParamValuegen_param_value are supported:

  • 'global_pooling_mode'"global_pooling_mode": Mode for calculation of the internally used kernel size and stride in case of global pooling (Modemodemode 'global_average'"global_average" or 'global_maximum'"global_maximum"). See description above. In case of a non-global pooling the parameter is set to the value 'undefined'"undefined".

    Default: 'overlapping'"overlapping"

  • 'is_inference_output'"is_inference_output": Determines whether apply_dl_modelApplyDlModel will include the output of this layer in the dictionary DLResultBatchDLResultBatchdlresult_batch even without specifying this layer in Outputsoutputsoutputs ('true'"true") or not ('false'"false").

    Default: 'false'"false"

Certain parameters of layers created using this operator create_dl_layer_poolingCreateDlLayerPooling can be set and retrieved using further operators. The following tables give an overview, which parameters can be set using set_dl_model_layer_paramSetDlModelLayerParam and which ones can be retrieved using get_dl_model_layer_paramGetDlModelLayerParam or get_dl_layer_paramGetDlLayerParam. Note, the operators set_dl_model_layer_paramSetDlModelLayerParam and get_dl_model_layer_paramGetDlModelLayerParam require a model created by create_dl_modelCreateDlModel.

Layer Parameters set get
'global'"global" x
'global_pooling_mode'"global_pooling_mode" x
'input_layer'"input_layer" (DLLayerInputDLLayerInputdllayer_input) x
'kernel_size'"kernel_size" (KernelSizekernelSizekernel_size) x
'name'"name" (LayerNamelayerNamelayer_name) x x
'output_layer'"output_layer" (DLLayerPoolingDLLayerPoolingdllayer_pooling) x
'padding'"padding" (Paddingpaddingpadding) x
'padding_type'"padding_type" (Paddingpaddingpadding) x
'pooling_mode'"pooling_mode" (Modemodemode) x
'shape'"shape" x
'stride'"stride" (Stridestridestride) x
'type'"type" x
Generic Layer Parameters set get
'is_inference_output'"is_inference_output" x x
'num_trainable_params'"num_trainable_params" x

Execution informationπŸ”—

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

ParametersπŸ”—

DLLayerInputDLLayerInputdllayer_input (input_control) dl_layer β†’ (handle)HTuple (HHandle)HDlLayer, HTuple (IntPtr)HHandleHtuple (handle)

Feeding layer.

LayerNamelayerNamelayer_name (input_control) string β†’ (string)HTuple (HString)HTuple (string)strHtuple (char*)

Name of the output layer.

KernelSizekernelSizekernel_size (input_control) number-array β†’ (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

Width and height of the filter kernels.

Default: [2, 2][2, 2]

Stridestridestride (input_control) number-array β†’ (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

Bi-dimensional amount of filter shift.

Default: [2, 2][2, 2]

Paddingpaddingpadding (input_control) number(-array) β†’ (string / integer)HTuple (HString / Hlong)HTuple (string / int / long)MaybeSequence[Union[str, int]]Htuple (char* / Hlong)

Padding type or specific padding size.

Default: 'none'"none"
Suggested values: 'none', 'half_kernel_size', 'implicit'"none", "half_kernel_size", "implicit"

Modemodemode (input_control) number β†’ (string)HTuple (HString)HTuple (string)strHtuple (char*)

Mode of pooling operation.

Default: 'maximum'"maximum"
List of values: 'average', 'global_average', 'global_maximum', 'maximum'"average", "global_average", "global_maximum", "maximum"

GenParamNamegenParamNamegen_param_name (input_control) attribute.name(-array) β†’ (string)HTuple (HString)HTuple (string)MaybeSequence[str]Htuple (char*)

Generic input parameter names.

Default: [][]
List of values: 'global_pooling_mode', 'is_inference_output'"global_pooling_mode", "is_inference_output"

GenParamValuegenParamValuegen_param_value (input_control) attribute.value(-array) β†’ (string / integer / real)HTuple (HString / Hlong / double)HTuple (string / int / long / double)MaybeSequence[Union[int, float, str]]Htuple (char* / Hlong / double)

Generic input parameter values.

Default: [][]
Suggested values: 'adaptive', 'non_overlapping', 'overlapping', 'true', 'false', 1.0, 0.9, 0.0"adaptive", "non_overlapping", "overlapping", "true", "false", 1.0, 0.9, 0.0

DLLayerPoolingDLLayerPoolingdllayer_pooling (output_control) dl_layer β†’ (handle)HTuple (HHandle)HDlLayer, HTuple (IntPtr)HHandleHtuple (handle)

Pooling layer.

ModuleπŸ”—

Deep Learning Professional