Skip to content

create_dl_layer_gatherCreateDlLayerGatherCreateDlLayerGathercreate_dl_layer_gatherT_create_dl_layer_gather🔗

Short description🔗

create_dl_layer_gatherCreateDlLayerGatherCreateDlLayerGathercreate_dl_layer_gatherT_create_dl_layer_gather — Create a gather layer.

Signature🔗

create_dl_layer_gather( dl_layer DLLayerInput, number Indices, string LayerName, number Axis, attribute.name GenParamName, attribute.value GenParamValue, out dl_layer DLLayerGather )void CreateDlLayerGather( const HTuple& DLLayerInput, const HTuple& Indices, const HTuple& LayerName, const HTuple& Axis, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* DLLayerGather )static void HOperatorSet.CreateDlLayerGather( HTuple DLLayerInput, HTuple indices, HTuple layerName, HTuple axis, HTuple genParamName, HTuple genParamValue, out HTuple DLLayerGather )def create_dl_layer_gather( dllayer_input: HHandle, indices: MaybeSequence[Union[int, HHandle]], layer_name: str, axis: Union[int, str], gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[Union[int, float, str]] ) -> HHandle

Herror T_create_dl_layer_gather( const Htuple DLLayerInput, const Htuple Indices, const Htuple LayerName, const Htuple Axis, const Htuple GenParamName, const Htuple GenParamValue, Htuple* DLLayerGather )

HDlLayer HDlLayer::CreateDlLayerGather( const HTuple& Indices, const HString& LayerName, const HTuple& Axis, const HTuple& GenParamName, const HTuple& GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerGather( Hlong Indices, const HString& LayerName, Hlong Axis, const HString& GenParamName, const HString& GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerGather( Hlong Indices, const char* LayerName, Hlong Axis, const char* GenParamName, const char* GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerGather( Hlong Indices, const wchar_t* LayerName, Hlong Axis, const wchar_t* GenParamName, const wchar_t* GenParamValue ) const (Windows only)

HDlLayer HDlLayer.CreateDlLayerGather( HTuple indices, string layerName, HTuple axis, HTuple genParamName, HTuple genParamValue )

HDlLayer HDlLayer.CreateDlLayerGather( int indices, string layerName, int axis, string genParamName, string genParamValue )

Description🔗

The operator create_dl_layer_gatherCreateDlLayerGather creates a gather layer that extracts slices from the input tensor DLLayerInputDLLayerInputdllayer_input along a specified axis, according to the indices provided. The handle of the gather layer is returned in DLLayerGatherDLLayerGatherdllayer_gather.

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

The parameter Indicesindicesindices defines the indices to be gathered from the axis. The indices must be either of rank 0 or rank 1, i.e., a scalar or a list. The indices input can be a layer handle (Indicesindicesindices) or a tuple of integers. If Indicesindicesindices is given as a tuple of integers, internally a constant input layer is created.

The axis along which the gathering is performed is specified by the parameter Axisaxisaxis. Axisaxisaxis can either be specified by a string ('width'"width", 'height'"height", 'depth'"depth" or 'batch'"batch") or an integer, where 0 corresponds to the batch size, 1 to depth, 2 to height and 3 to width. Negative values for Axisaxisaxis indicate counting dimensions from the back. The accepted range is [-4,3].

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.

Gather semantics

Given a 4-dimensional input tensor DLLayerInputDLLayerInputdllayer_input of shape \((N, C, H, W)\) and an indices tensor or tuple, the gather layer selects elements from the Axisaxisaxis dimension indexed by elements of Indicesindicesindices.

If the indices are given as a tuple \((i_{0}, \dots, i_{k})\) and Axisaxisaxis \(=a\), the output tensor is constructed by replacing dimension \(a\) with the indices dimensions, resulting in an output of shape \((d_{0}, \dots, d_{a-1}, k+1, d_{a+1}, \dots, d_{r-1})\)

All index values in Indicesindicesindices must be within the bounds \([-s, s-1]\), where \(s\) is the size of the Axisaxisaxis dimension. Negative indices are interpreted by adding \(s\), i.e., 'index'"index"\(=\)'index'"index"\(+ s\) if 'index'"index"\(< 0\).

Index Processing

  • Adjusting Axis Negative values for Axisaxisaxis are made non-negative by adding the number of dimensions \(r\) of the input tensor:

    \[\begin{eqnarray*} \textrm{axis} \gets \textrm{axis} + r \qquad \textrm{if } \textrm{axis} < 0 \end{eqnarray*}\]
  • Clamping Indices Negative values in Indicesindicesindices are adjusted by adding the size \(s\) of the corresponding axis:

    \[\begin{eqnarray*} \textrm{indices}[j] \gets \textrm{indices}[j] + s \qquad \textrm{if } \textrm{indices}[j] < 0 \end{eqnarray*}\]

    All values in Indicesindicesindices must satisfy

    \[\begin{eqnarray*} 0 \leq \textrm{indices}[j] < s \end{eqnarray*}\]

    Otherwise, an error will be raised.

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").

    List of values: 'true'"true", 'false'"false"

    Default: 'false'"false"

Certain parameters of layers created using this operator create_dl_layer_gatherCreateDlLayerGather 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
'input_layer'"input_layer" (DLLayerInputDLLayerInputdllayer_input,Indicesindicesindices) x
'name'"name" (LayerNamelayerNamelayer_name) x x
'axis'"axis" (Axisaxisaxis) x
'output_layer'"output_layer" (DLLayerGatherDLLayerGatherdllayer_gather) 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

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 data input layer.

Default: 'DLLayerInput'"DLLayerInput"

Indicesindicesindices (input_control) number(-array) → (integer / handle)HTuple (Hlong / HHandle)HTuple (int / long / HHandle)MaybeSequence[Union[int, HHandle]]Htuple (Hlong / handle)

Indices for the gather operation. This input can be a layer or tuple of integers.

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

Name of the output layer.

Axisaxisaxis (input_control) number → (integer / string)HTuple (Hlong / HString)HTuple (int / long / string)Union[int, str]Htuple (Hlong / char*)

Axis along which to gather.

Default: 00
Suggested values: 0, 'batch', 1, 'depth', 2, 'height', 3, 'width'0, "batch", 1, "depth", 2, "height", 3, "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: '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"

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

Output layer.

Module🔗

Deep Learning Professional