Skip to content

create_dl_layer_reduceCreateDlLayerReduceCreateDlLayerReducecreate_dl_layer_reduceT_create_dl_layer_reduce🔗

Short description🔗

create_dl_layer_reduceCreateDlLayerReduceCreateDlLayerReducecreate_dl_layer_reduceT_create_dl_layer_reduce — Create a reduce layer.

Signature🔗

create_dl_layer_reduce( dl_layer DLLayerInput, string LayerName, string Operation, integer Axes, attribute.name GenParamName, attribute.value GenParamValue, out dl_layer DLLayerReduce )void CreateDlLayerReduce( const HTuple& DLLayerInput, const HTuple& LayerName, const HTuple& Operation, const HTuple& Axes, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* DLLayerReduce )static void HOperatorSet.CreateDlLayerReduce( HTuple DLLayerInput, HTuple layerName, HTuple operation, HTuple axes, HTuple genParamName, HTuple genParamValue, out HTuple DLLayerReduce )def create_dl_layer_reduce( dllayer_input: HHandle, layer_name: str, operation: str, axes: MaybeSequence[Union[int, str]], gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[Union[int, float, str]] ) -> HHandle

Herror T_create_dl_layer_reduce( const Htuple DLLayerInput, const Htuple LayerName, const Htuple Operation, const Htuple Axes, const Htuple GenParamName, const Htuple GenParamValue, Htuple* DLLayerReduce )

HDlLayer HDlLayer::CreateDlLayerReduce( const HString& LayerName, const HString& Operation, const HTuple& Axes, const HTuple& GenParamName, const HTuple& GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerReduce( const HString& LayerName, const HString& Operation, Hlong Axes, const HString& GenParamName, const HString& GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerReduce( const char* LayerName, const char* Operation, Hlong Axes, const char* GenParamName, const char* GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerReduce( const wchar_t* LayerName, const wchar_t* Operation, Hlong Axes, const wchar_t* GenParamName, const wchar_t* GenParamValue ) const (Windows only)

HDlLayer HDlLayer.CreateDlLayerReduce( string layerName, string operation, HTuple axes, HTuple genParamName, HTuple genParamValue )

HDlLayer HDlLayer.CreateDlLayerReduce( string layerName, string operation, int axes, string genParamName, string genParamValue )

Description🔗

The operator create_dl_layer_reduceCreateDlLayerReduce creates a reduce layer whose handle is returned in DLLayerReduceDLLayerReducedllayer_reduce.

A reduce layer applies a given operation to the input data tensor to reduce it along one or multiple axes to a single value. Hence, the output tensor has the same shape as the input tensor, but at the axes given by Axesaxesaxes the dimension equals one.

The parameter DLLayerInputDLLayerInputdllayer_input determines the feeding input layer. This layer expects a single layer as input.

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 Operationoperationoperation specifies the operation that is applied. The operation is applied to the values along the axes given by Axesaxesaxes of the input tensor and the result is written to the corresponding position in the output tensor. The supported values for Operationoperationoperation are:

  • 'norm_l2'"norm_l2": Computes the L2 norm of the input values.

  • 'sum'"sum": Computes the sum of the input values.

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

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

  • 'div_eps'"div_eps": Small scalar value that is used to stabilize the training. I.e., in case of a division, the value is added to the denominator to prevent a division by zero.

    Default: 1e-101e-10

Certain parameters of layers created using this operator create_dl_layer_reduceCreateDlLayerReduce 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
'axes'"axes" (Axesaxesaxes) x
'input_layer'"input_layer" (DLLayerInputDLLayerInputdllayer_input) x
'name'"name" (LayerNamelayerNamelayer_name) x x
'operation'"operation" (Operationoperationoperation) x
'output_layer'"output_layer" (DLLayerReduceDLLayerReducedllayer_reduce) x
'shape'"shape" x
'type'"type" x
Generic Layer Parameters set get
'is_inference_output'"is_inference_output" x x
'num_trainable_params'"num_trainable_params" x
'div_eps'"div_eps" 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 input layer.

LayerNamelayerNamelayer_name (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

Name of the output layer.

Operationoperationoperation (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

Reduce operation.

Default: 'norm_l2'"norm_l2"
List of values: 'norm_l2', 'sum'"norm_l2", "sum"

Axesaxesaxes (input_control) integer(-array) → (integer / string)HTuple (Hlong / HString)HTuple (int / long / string)MaybeSequence[Union[int, str]]Htuple (Hlong / char*)

Axes to which the reduce operation is applied.

Default: [2, 3][2, 3]
List of values: 0, 1, 2, 3, 'batch', 'depth', 'height', 'width'0, 1, 2, 3, "batch", "depth", "height", "width"

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: 'div_eps', 'is_inference_output'"div_eps", "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: 1e-10, 'true', 'false'1e-10, "true", "false"

DLLayerReduceDLLayerReducedllayer_reduce (output_control) dl_layer → (handle)HTuple (HHandle)HDlLayer, HTuple (IntPtr)HHandleHtuple (handle)

Reduce layer.

Example🔗

(HDevelop)

* Minimal example for reduce-layer.
create_dl_layer_input ('input', [64, 32, 10], [], [], DLLayerInput)
create_dl_layer_reduce (DLLayerInput, 'reduce_width', 'sum', 'width', [], [], \
                         DLLayerReduceWidth)
create_dl_layer_reduce (DLLayerReduceWidth, 'reduce_height_depth', 'norm_l2',  [1,2], [], \
                         [], DLLayerReduceHeightDepth)
* Create a model and change the batch-size.
create_dl_model (DLLayerReduceHeightDepth, DLModel)
set_dl_model_param (DLModel, 'batch_size', 2)
get_dl_model_layer_param (DLModel, 'reduce_height_depth', 'shape', ShapeReduceHeightWidth)

Combinations with other operators🔗

Combinations

Possible predecessors

create_dl_layer_inputCreateDlLayerInput

Possible successors

create_dl_modelCreateDlModel

Module🔗

Deep Learning Professional