Skip to content

create_dl_layer_convolutionCreateDlLayerConvolutionCreateDlLayerConvolutioncreate_dl_layer_convolutionT_create_dl_layer_convolution๐Ÿ”—

Short description๐Ÿ”—

create_dl_layer_convolutionCreateDlLayerConvolutionCreateDlLayerConvolutioncreate_dl_layer_convolutionT_create_dl_layer_convolution โ€” Create a convolutional layer.

Signature๐Ÿ”—

create_dl_layer_convolution( dl_layer DLLayerInput, string LayerName, number KernelSize, number Dilation, number Stride, number NumKernel, number Groups, number Padding, number Activation, attribute.name GenParamName, attribute.value GenParamValue, out dl_layer DLLayerConvolution )void CreateDlLayerConvolution( const HTuple& DLLayerInput, const HTuple& LayerName, const HTuple& KernelSize, const HTuple& Dilation, const HTuple& Stride, const HTuple& NumKernel, const HTuple& Groups, const HTuple& Padding, const HTuple& Activation, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* DLLayerConvolution )static void HOperatorSet.CreateDlLayerConvolution( HTuple DLLayerInput, HTuple layerName, HTuple kernelSize, HTuple dilation, HTuple stride, HTuple numKernel, HTuple groups, HTuple padding, HTuple activation, HTuple genParamName, HTuple genParamValue, out HTuple DLLayerConvolution )def create_dl_layer_convolution( dllayer_input: HHandle, layer_name: str, kernel_size: MaybeSequence[int], dilation: MaybeSequence[int], stride: MaybeSequence[int], num_kernel: int, groups: int, padding: MaybeSequence[Union[str, int]], activation: str, gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[Union[int, float, str]] ) -> HHandle

Herror T_create_dl_layer_convolution( const Htuple DLLayerInput, const Htuple LayerName, const Htuple KernelSize, const Htuple Dilation, const Htuple Stride, const Htuple NumKernel, const Htuple Groups, const Htuple Padding, const Htuple Activation, const Htuple GenParamName, const Htuple GenParamValue, Htuple* DLLayerConvolution )

HDlLayer HDlLayer::CreateDlLayerConvolution( const HString& LayerName, const HTuple& KernelSize, const HTuple& Dilation, const HTuple& Stride, Hlong NumKernel, Hlong Groups, const HTuple& Padding, const HString& Activation, const HTuple& GenParamName, const HTuple& GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerConvolution( const HString& LayerName, Hlong KernelSize, Hlong Dilation, Hlong Stride, Hlong NumKernel, Hlong Groups, const HString& Padding, const HString& Activation, const HString& GenParamName, const HString& GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerConvolution( const char* LayerName, Hlong KernelSize, Hlong Dilation, Hlong Stride, Hlong NumKernel, Hlong Groups, const char* Padding, const char* Activation, const char* GenParamName, const char* GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerConvolution( const wchar_t* LayerName, Hlong KernelSize, Hlong Dilation, Hlong Stride, Hlong NumKernel, Hlong Groups, const wchar_t* Padding, const wchar_t* Activation, const wchar_t* GenParamName, const wchar_t* GenParamValue ) const (Windows only)

HDlLayer HDlLayer.CreateDlLayerConvolution( string layerName, HTuple kernelSize, HTuple dilation, HTuple stride, int numKernel, int groups, HTuple padding, string activation, HTuple genParamName, HTuple genParamValue )

HDlLayer HDlLayer.CreateDlLayerConvolution( string layerName, int kernelSize, int dilation, int stride, int numKernel, int groups, string padding, string activation, string genParamName, string genParamValue )

Description๐Ÿ”—

The operator create_dl_layer_convolutionCreateDlLayerConvolution creates a convolutional layer with NumKernelnumKernelnum_kernel kernels in Groupsgroupsgroups filter groups whose handle is returned in DLLayerConvolutionDLLayerConvolutiondllayer_convolution.

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 Dilationdilationdilation specifies the factor of filter dilation in the dimensions width and height.

The parameter Stridestridestride specifies how the filter is shifted.

The values for KernelSizekernelSizekernel_size, Dilationdilationdilation, 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 Groupsgroupsgroups specifies the number of filter groups.

The parameter NumKernelnumKernelnum_kernel specifies the number of filter kernels. NumKernelnumKernelnum_kernel must be a multiple of Groupsgroupsgroups.

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 specified 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.

  • '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 convolution layer are given by

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

Thereby we use the following values: \(output\_dim\): output width/height, \(input\_dim\): input width/height, \(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 Activationactivationactivation determines whether an activation is performed after the convolution in order to optimize the runtime performance. The following values are supported:

  • 'relu'"relu": perform a ReLU activation after the convolution.

  • 'sigmoid'"sigmoid": perform a Sigmoid activation after the convolution.

  • 'tanh'"tanh": perform a Tanh activation after the convolution.

    It is possible to specify an upper bound to the ReLU operation (see create_dl_layer_activationCreateDlLayerActivation) via the generic parameter 'upper_bound'"upper_bound". Note: It is not possible to specify a leaky ReLU.

  • 'none'"none": no activation operation is performed.

We refer to the โ€œSolution Guide on Classificationโ€ for more general information about the convolution layer and the reference given below for more detailed information about the arithmetic of the layer.

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

  • 'bias_filler'"bias_filler": See 'weight_filler'"weight_filler" for an explanation of the values.

    List of values: 'xavier'"xavier", 'msra'"msra", 'const'"const".

    Default: 'const'"const"

  • 'bias_filler_variance_norm'"bias_filler_variance_norm": See 'weight_filler_variance_norm'"weight_filler_variance_norm" for an explanation of the values.

    List of values: 'norm_in'"norm_in", 'norm_out'"norm_out", 'norm_average'"norm_average".

    Default: 'norm_in'"norm_in"

  • 'bias_filler_const_val'"bias_filler_const_val": Specifies the constant bias term initialization value if 'bias_filler'"bias_filler" has been set to 'const'"const".

    Restriction: Ignored for other values of 'bias_filler'"bias_filler".

    Default: 00

  • 'bias_term'"bias_term": Determines whether the created convolutional layer has a bias term ('true'"true") or not ('false'"false").

    Default: 'true'"true"

  • '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"

  • 'learning_rate_multiplier'"learning_rate_multiplier": Multiplier for the learning rate for this layer that is used during training. If 'learning_rate_multiplier'"learning_rate_multiplier" is set to 0.00.0, the layer is skipped during training.

    Default: 1.01.0

  • 'learning_rate_multiplier_bias'"learning_rate_multiplier_bias": Multiplier for the learning rate of the bias term. The total bias learning rate is the product of 'learning_rate_multiplier_bias'"learning_rate_multiplier_bias" and 'learning_rate_multiplier'"learning_rate_multiplier".

    Default: 1.01.0

  • 'upper_bound'"upper_bound": Float value, which defines the upper bound for ReLU. To unset the upper bound, set 'upper_bound'"upper_bound" to an empty tuple.

    Default: [][]

  • 'weight_filler'"weight_filler": This parameter defines the mode how the weights are initialized. The following values are supported:

    • 'const'"const": The weights are filled with constant values.

    • 'msra'"msra": The weights are drawn from a Gaussian distribution.

    • 'xavier'"xavier": The weights are drawn from a uniform distribution.

    Default: 'xavier'"xavier"

  • 'weight_filler_const_val'"weight_filler_const_val": Specifies the constant weight initialization value.

    Restriction: Only applied if 'weight_filler'"weight_filler" = 'const'"const".

    Default: 0.50.5

  • 'weight_filler_variance_norm'"weight_filler_variance_norm": This parameter determines the value range for 'weight_filler'"weight_filler". The following values are supported:

    • 'norm_average'"norm_average": the values are based on the average of the input and output size

    • 'norm_in'"norm_in": the values are based on the input size

    • 'norm_out'"norm_out": the values are based on the output size.

    Default: 'norm_in'"norm_in"

Certain parameters of layers created using create_dl_layer_convolutionCreateDlLayerConvolution 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
'activation_mode'"activation_mode" (Activationactivationactivation) x
'dilation'"dilation" (Dilationdilationdilation) x
'groups'"groups" (Groupsgroupsgroups) x
'input_depth'"input_depth" x
'input_layer'"input_layer" (DLLayerInputDLLayerInputdllayer_input) x
'kernel_size'"kernel_size" (KernelSizekernelSizekernel_size) x
'name'"name" (LayerNamelayerNamelayer_name) x x
'num_kernels'"num_kernels" (NumKernelnumKernelnum_kernel) x
'output_layer'"output_layer" (DLLayerConvolutionDLLayerConvolutiondllayer_convolution) x
'padding'"padding" (Paddingpaddingpadding) x
'padding_type'"padding_type" (Paddingpaddingpadding) x
'shape'"shape" x
'stride'"stride" (Stridestridestride) x
'type'"type" x
Generic Layer Parameters set get
'bias_filler'"bias_filler" x x
'bias_filler_const_val'"bias_filler_const_val" x x
'bias_filler_variance_norm'"bias_filler_variance_norm" x x
'bias_term'"bias_term" x
'is_inference_output'"is_inference_output" x x
'learning_rate_multiplier'"learning_rate_multiplier" x x
'learning_rate_multiplier_bias'"learning_rate_multiplier_bias" x x
'num_trainable_params'"num_trainable_params" x
'upper_bound'"upper_bound" x x
'weight_filler'"weight_filler" x x
'weight_filler_const_val'"weight_filler_const_val" x x
'weight_filler_variance_norm'"weight_filler_variance_norm" x 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)MaybeSequence[int]Htuple (Hlong)

Width and height of the filter kernels.

Default: 33

Dilationdilationdilation (input_control) number(-array) โ†’ (integer)HTuple (Hlong)HTuple (int / long)MaybeSequence[int]Htuple (Hlong)

Amount of filter dilation for width and height.

Default: 11

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

Amount of filter shift in width and height direction.

Default: 11

NumKernelnumKernelnum_kernel (input_control) number โ†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Number of filter kernels.

Default: 6464

Groupsgroupsgroups (input_control) number โ†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Number of filter groups.

Default: 11

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"
List of values: [all], [width, height], [left, right, top, bottom], 'half_kernel_size', 'none'[all], [width, height], [left, right, top, bottom], "half_kernel_size", "none"
Suggested values: 'none', 'half_kernel_size'"none", "half_kernel_size"

Activationactivationactivation (input_control) number โ†’ (string)HTuple (HString)HTuple (string)strHtuple (char*)

Enable optional ReLU, sigmoid or tanh activations.

Default: 'none'"none"
List of values: 'none', 'relu', 'sigmoid', 'tanh'"none", "relu", "sigmoid", "tanh"

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: 'bias_filler', 'bias_filler_const_val', 'bias_filler_variance_norm', 'bias_term', 'is_inference_output', 'learning_rate_multiplier', 'learning_rate_multiplier_bias', 'upper_bound', 'weight_filler', 'weight_filler_const_val', 'weight_filler_variance_norm'"bias_filler", "bias_filler_const_val", "bias_filler_variance_norm", "bias_term", "is_inference_output", "learning_rate_multiplier", "learning_rate_multiplier_bias", "upper_bound", "weight_filler", "weight_filler_const_val", "weight_filler_variance_norm"

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: 'xavier', 'msra', 'const', 'nearest_neighbor', 'bilinear', 'norm_in', 'norm_out', 'norm_average', 'true', 'false', 1.0, 0.9, 0.0"xavier", "msra", "const", "nearest_neighbor", "bilinear", "norm_in", "norm_out", "norm_average", "true", "false", 1.0, 0.9, 0.0

DLLayerConvolutionDLLayerConvolutiondllayer_convolution (output_control) dl_layer โ†’ (handle)HTuple (HHandle)HDlLayer, HTuple (IntPtr)HHandleHtuple (handle)

Convolutional layer.

References๐Ÿ”—

V. Dumoulin, F. Visin: "A guide to convolution arithmetic for deep learningโ€, 2018, http://arxiv.org/abs/1603.07285

Module๐Ÿ”—

Deep Learning Professional