Skip to content

create_dl_layer_elementwiseCreateDlLayerElementwiseCreateDlLayerElementwisecreate_dl_layer_elementwiseT_create_dl_layer_elementwise🔗

Short description🔗

create_dl_layer_elementwiseCreateDlLayerElementwiseCreateDlLayerElementwisecreate_dl_layer_elementwiseT_create_dl_layer_elementwise — Create an elementwise layer.

Signature🔗

create_dl_layer_elementwise( dl_layer DLLayerInputs, string LayerName, string Operation, number Coefficients, attribute.name GenParamName, attribute.value GenParamValue, out dl_layer DLLayerElementWise )void CreateDlLayerElementwise( const HTuple& DLLayerInputs, const HTuple& LayerName, const HTuple& Operation, const HTuple& Coefficients, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* DLLayerElementWise )static void HOperatorSet.CreateDlLayerElementwise( HTuple DLLayerInputs, HTuple layerName, HTuple operation, HTuple coefficients, HTuple genParamName, HTuple genParamValue, out HTuple DLLayerElementWise )def create_dl_layer_elementwise( dllayer_inputs: MaybeSequence[HHandle], layer_name: str, operation: str, coefficients: MaybeSequence[float], gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[Union[int, float, str]] ) -> HHandle

Herror T_create_dl_layer_elementwise( const Htuple DLLayerInputs, const Htuple LayerName, const Htuple Operation, const Htuple Coefficients, const Htuple GenParamName, const Htuple GenParamValue, Htuple* DLLayerElementWise )

static HDlLayer HDlLayer::CreateDlLayerElementwise( const HDlLayerArray& DLLayerInputs, const HString& LayerName, const HString& Operation, const HTuple& Coefficients, const HTuple& GenParamName, const HTuple& GenParamValue )

HDlLayer HDlLayer::CreateDlLayerElementwise( const HString& LayerName, const HString& Operation, double Coefficients, const HString& GenParamName, const HString& GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerElementwise( const char* LayerName, const char* Operation, double Coefficients, const char* GenParamName, const char* GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerElementwise( const wchar_t* LayerName, const wchar_t* Operation, double Coefficients, const wchar_t* GenParamName, const wchar_t* GenParamValue ) const (Windows only)

static HDlLayer HDlLayer.CreateDlLayerElementwise( HDlLayer[] DLLayerInputs, string layerName, string operation, HTuple coefficients, HTuple genParamName, HTuple genParamValue )

HDlLayer HDlLayer.CreateDlLayerElementwise( string layerName, string operation, double coefficients, string genParamName, string genParamValue )

Description🔗

The operator create_dl_layer_elementwiseCreateDlLayerElementwise creates an element-wise layer whose handle is returned in DLLayerElementWiseDLLayerElementWisedllayer_element_wise.

An elementwise layer applies a certain operation to every data tensor of the input layers handles and to each element of the data tensor. As a consequence, all input data tensors should be of the same shape and the output tensor has the same shape as the first input tensor.

The parameter DLLayerInputsDLLayerInputsdllayer_inputs determines the feeding input layers. This layer expects multiple layers as input. For Operationoperationoperation = 'division'"division" exactly two input layers are expected.

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. Depending on Operationoperationoperation, the layer supports implicit unidirectional broadcasting, i.e. there must be one input that has the “full” shape, which is also the output shape (batch_size, depth, height, width). All other inputs can have for each dimension a size equal to this dimension or 1. If one of the dimensions is 1, the values are implicitly broadcasted along that dimension to match the full shape. The supported values are:

  • 'division'"division": Element-wise division. Broadcasting is supported, but only from the first to the second input, i.e., the first input must have the full shape.

  • 'maximum'"maximum": Element-wise maximum. Broadcasting is fully supported.

  • 'minimum'"minimum": Element-wise minimum. Broadcasting is fully supported.

  • 'product'"product": Element-wise product. Broadcasting is supported, but all inputs that do not have the full shape must have the same shape. Either all inputs have the full shape or only exactly one.

  • 'sum'"sum": Element-wise summation. Broadcasting is fully supported.

Note, that broadcasting may be slower than all inputs having the same shape.

The optional parameter Coefficientscoefficientscoefficients determines a weighting coefficient for every input tensor. The number of values in Coefficientscoefficientscoefficients must match the number of feeding layers in DLLayerInputsDLLayerInputsdllayer_inputs. Set Coefficientscoefficientscoefficients equal to [][] if no coefficients shall be used in the element-wise operation.

Restriction: No coefficients can be set for Operationoperationoperation = 'product'"product".

Example: for Operationoperationoperation = 'sum'"sum", the \(i\)-th element of the output data tensor is given by

\[\begin{eqnarray*} output[i] = \sum_{n=0}^{N-1}\textrm{Coefficients}[n] \cdot \textrm{DLLayerInputs}_{n}[i], \end{eqnarray*}\]

where \(N\) is the number of input data tensors.

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

  • 'div_eps'"div_eps": Small scalar value that is added to the elements of the denominator to avoid a division by zero (for Operationoperationoperation = 'division'"division").

    Default: 1e-101e-10

  • '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_elementwiseCreateDlLayerElementwise 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
'coefficients'"coefficients" (Coefficientscoefficientscoefficients) x x
'input_layer'"input_layer" (DLLayerInputsDLLayerInputsdllayer_inputs) x
'name'"name" (LayerNamelayerNamelayer_name) x x
'operation'"operation" (Operationoperationoperation) x
'output_layer'"output_layer" (DLLayerElementWiseDLLayerElementWisedllayer_element_wise) x
'shape'"shape" x
'type'"type" x
Generic Layer Parameters set get
'div_eps'"div_eps" x x
'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🔗

DLLayerInputsDLLayerInputsdllayer_inputs (input_control) dl_layer(-array) → (handle)HTuple (HHandle)HDlLayer, HTuple (IntPtr)MaybeSequence[HHandle]Htuple (handle)

Feeding input layers.

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*)

Element-wise operations.

Default: 'sum'"sum"
List of values: 'division', 'maximum', 'minimum', 'product', 'sum'"division", "maximum", "minimum", "product", "sum"

Coefficientscoefficientscoefficients (input_control) number(-array) → (real)HTuple (double)HTuple (double)MaybeSequence[float]Htuple (double)

Optional input tensor coefficients.

Default: [][]

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: 'is_inference_output'"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: 'true', 'false'"true", "false"

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

Elementwise layer.

Module🔗

Deep Learning Professional