Operator Reference

create_dl_layer_poolingT_create_dl_layer_poolingCreateDlLayerPoolingCreateDlLayerPoolingcreate_dl_layer_pooling (Operator)

create_dl_layer_poolingT_create_dl_layer_poolingCreateDlLayerPoolingCreateDlLayerPoolingcreate_dl_layer_pooling — Create a pooling layer.

Signature

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)

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)

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)

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

Description

The operator create_dl_layer_poolingcreate_dl_layer_poolingCreateDlLayerPoolingCreateDlLayerPoolingcreate_dl_layer_pooling creates a pooling layer whose handle is returned in DLLayerPoolingDLLayerPoolingDLLayerPoolingDLLayerPoolingdllayer_pooling.

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

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

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

The parameter StrideStrideStridestridestride specifies how the filter is shifted.

The values for KernelSizeKernelSizeKernelSizekernelSizekernel_size and StrideStrideStridestridestride can be set as

  • a single value which is used for both dimensions

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

The parameter PaddingPaddingPaddingpaddingpadding 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""half_kernel_size""half_kernel_size""half_kernel_size": The number of appended pixels depends on the specifies KernelSizeKernelSizeKernelSizekernelSizekernel_size. More precisely, it is calculated as , where for the padding on the left / right border the value of KernelSizeKernelSizeKernelSizekernelSizekernel_size in dimension width is regarded and for the padding on the upper / lower border the value of KernelSizeKernelSizeKernelSizekernelSizekernel_size in height.

  • 'implicit'"implicit""implicit""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 , or zero if the kernel size is a divisor of the input dimension. stands for the input width or height.

  • 'none'"none""none""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""runtime""runtime""runtime" 'gpu'"gpu""gpu""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 KernelSizeKernelSizeKernelSizekernelSizekernel_size in the corresponding dimension.

The output dimensions of the pooling layer are given by Thereby we use the following values: : output width, : input width, : number of pixels added to the left/top of the input image, and : number of pixels added to the right/bottom of the input image.

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

'average'"average""average""average""average":

The resulting pixel value is the average of all pixel values in the filter.

'maximum'"maximum""maximum""maximum""maximum":

The resulting pixel value is the maximum of all pixel values in the filter.

'global_average'"global_average""global_average""global_average""global_average":

Same as mode 'average'"average""average""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 KernelSizeKernelSizeKernelSizekernelSizekernel_size. E.g., if the average over all pixel values of the input shall be returned, set the KernelSizeKernelSizeKernelSizekernelSizekernel_size to 1 and the output width and height is equal to 1. The internally used kernel size and stride are calculated as follows:

  • If KernelSizeKernelSizeKernelSizekernelSizekernel_size is a divisor of the input dimensions: The internally used kernel size and stride are both set to the value .

  • If KernelSizeKernelSizeKernelSizekernelSizekernel_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""global_pooling_mode""global_pooling_mode""global_pooling_mode":

    'overlapping'"overlapping""overlapping""overlapping""overlapping":

    The internally used is set to . The internally used kernel size is then computed as . This leads to overlapping kernels but the whole input image is taken into account for the computation of the output.

    'non_overlapping'"non_overlapping""non_overlapping""non_overlapping""non_overlapping":

    The internally used kernel size and stride are set to the same value . 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 KernelSizeKernelSizeKernelSizekernelSizekernel_size.

    'adaptive'"adaptive""adaptive""adaptive""adaptive":

    In this mode, for each pixel of the output, the size of the corresponding pooling area within the input is computed adaptively, where are the row and are the column indices of the output. The row indices of the pooling area for pixels of the -th output row are given by , where in this case the height of the KernelSizeKernelSizeKernelSizekernelSizekernel_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""global_pooling_mode""global_pooling_mode""global_pooling_mode" 'overlapping'"overlapping""overlapping""overlapping""overlapping". The whole input image is taken into account for the computation of the output. For this mode, the parameter PaddingPaddingPaddingpaddingpadding must be set to 'none'"none""none""none""none".

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

'global_maximum'"global_maximum""global_maximum""global_maximum""global_maximum":

Same as mode 'global_average'"global_average""global_average""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 GenParamNameGenParamNameGenParamNamegenParamNamegen_param_name and the corresponding values GenParamValueGenParamValueGenParamValuegenParamValuegen_param_value are supported:

'global_pooling_mode'"global_pooling_mode""global_pooling_mode""global_pooling_mode""global_pooling_mode":

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

Default: 'overlapping'"overlapping""overlapping""overlapping""overlapping"

'is_inference_output'"is_inference_output""is_inference_output""is_inference_output""is_inference_output":

Determines whether apply_dl_modelapply_dl_modelApplyDlModelApplyDlModelapply_dl_model will include the output of this layer in the dictionary DLResultBatchDLResultBatchDLResultBatchDLResultBatchdlresult_batch even without specifying this layer in OutputsOutputsOutputsoutputsoutputs ('true'"true""true""true""true") or not ('false'"false""false""false""false").

Default: 'false'"false""false""false""false"

Certain parameters of layers created using this operator create_dl_layer_poolingcreate_dl_layer_poolingCreateDlLayerPoolingCreateDlLayerPoolingcreate_dl_layer_pooling can be set and retrieved using further operators. The following tables give an overview, which parameters can be set using set_dl_model_layer_paramset_dl_model_layer_paramSetDlModelLayerParamSetDlModelLayerParamset_dl_model_layer_param and which ones can be retrieved using get_dl_model_layer_paramget_dl_model_layer_paramGetDlModelLayerParamGetDlModelLayerParamget_dl_model_layer_param or get_dl_layer_paramget_dl_layer_paramGetDlLayerParamGetDlLayerParamget_dl_layer_param. Note, the operators set_dl_model_layer_paramset_dl_model_layer_paramSetDlModelLayerParamSetDlModelLayerParamset_dl_model_layer_param and get_dl_model_layer_paramget_dl_model_layer_paramGetDlModelLayerParamGetDlModelLayerParamget_dl_model_layer_param require a model created by create_dl_modelcreate_dl_modelCreateDlModelCreateDlModelcreate_dl_model.

Layer Parameters set get
'global'"global""global""global""global" x
'global_pooling_mode'"global_pooling_mode""global_pooling_mode""global_pooling_mode""global_pooling_mode" x
'input_layer'"input_layer""input_layer""input_layer""input_layer" (DLLayerInputDLLayerInputDLLayerInputDLLayerInputdllayer_input) x
'kernel_size'"kernel_size""kernel_size""kernel_size""kernel_size" (KernelSizeKernelSizeKernelSizekernelSizekernel_size) x
'name'"name""name""name""name" (LayerNameLayerNameLayerNamelayerNamelayer_name) x x
'output_layer'"output_layer""output_layer""output_layer""output_layer" (DLLayerPoolingDLLayerPoolingDLLayerPoolingDLLayerPoolingdllayer_pooling) x
'padding'"padding""padding""padding""padding" (PaddingPaddingPaddingpaddingpadding) x
'padding_type'"padding_type""padding_type""padding_type""padding_type" (PaddingPaddingPaddingpaddingpadding) x
'pooling_mode'"pooling_mode""pooling_mode""pooling_mode""pooling_mode" (ModeModeModemodemode) x
'shape'"shape""shape""shape""shape" x
'stride'"stride""stride""stride""stride" (StrideStrideStridestridestride) x
'type'"type""type""type""type" x
Generic Layer Parameters set get
'is_inference_output'"is_inference_output""is_inference_output""is_inference_output""is_inference_output" x x
'num_trainable_params'"num_trainable_params""num_trainable_params""num_trainable_params""num_trainable_params" x

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

DLLayerInputDLLayerInputDLLayerInputDLLayerInputdllayer_input (input_control)  dl_layer HDlLayer, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Feeding layer.

LayerNameLayerNameLayerNamelayerNamelayer_name (input_control)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Name of the output layer.

KernelSizeKernelSizeKernelSizekernelSizekernel_size (input_control)  number-array HTupleSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Width and height of the filter kernels.

Default: [2,2]

StrideStrideStridestridestride (input_control)  number-array HTupleSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Bi-dimensional amount of filter shift.

Default: [2,2]

PaddingPaddingPaddingpaddingpadding (input_control)  number(-array) HTupleMaybeSequence[Union[str, int]]HTupleHtuple (string / integer) (string / int / long) (HString / Hlong) (char* / Hlong)

Padding type or specific padding size.

Default: 'none' "none" "none" "none" "none"

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

ModeModeModemodemode (input_control)  number HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Mode of pooling operation.

Default: 'maximum' "maximum" "maximum" "maximum" "maximum"

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

GenParamNameGenParamNameGenParamNamegenParamNamegen_param_name (input_control)  attribute.name(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Generic input parameter names.

Default: []

List of values: 'global_pooling_mode'"global_pooling_mode""global_pooling_mode""global_pooling_mode""global_pooling_mode", 'is_inference_output'"is_inference_output""is_inference_output""is_inference_output""is_inference_output"

GenParamValueGenParamValueGenParamValuegenParamValuegen_param_value (input_control)  attribute.value(-array) HTupleMaybeSequence[Union[int, float, str]]HTupleHtuple (string / integer / real) (string / int / long / double) (HString / Hlong / double) (char* / Hlong / double)

Generic input parameter values.

Default: []

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

DLLayerPoolingDLLayerPoolingDLLayerPoolingDLLayerPoolingdllayer_pooling (output_control)  dl_layer HDlLayer, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Pooling layer.

Module

Deep Learning Professional