HALCON Operator reference

create_dl_layer_gatherT_create_dl_layer_gatherCreateDlLayerGatherCreateDlLayerGathercreate_dl_layer_gather (Operator)

create_dl_layer_gatherT_create_dl_layer_gatherCreateDlLayerGatherCreateDlLayerGathercreate_dl_layer_gather — Create a gather layer.

Signature

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)

void CreateDlLayerGather(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)

static void HOperatorSet.CreateDlLayerGather(HTuple DLLayerInput, HTuple indices, HTuple layerName, HTuple axis, HTuple genParamName, HTuple genParamValue, out HTuple DLLayerGather)

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)

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

Description

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

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

The parameter IndicesIndicesIndicesindicesindices 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 (IndicesIndicesIndicesindicesindices) or a tuple of integers. If IndicesIndicesIndicesindicesindices 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 AxisAxisAxisaxisaxis. AxisAxisAxisaxisaxis can either be specified by a string ('width'"width""width""width""width", 'height'"height""height""height""height", 'depth'"depth""depth""depth""depth" or 'batch'"batch""batch""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 AxisAxisAxisaxisaxis indicate counting dimensions from the back. The accepted range is [-4,3].

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.

Gather semantics

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

If the indices are given as a tuple and AxisAxisAxisaxisaxis , the output tensor is constructed by replacing dimension with the indices dimensions, resulting in an output of shape

All index values in IndicesIndicesIndicesindicesindices must be within the bounds , where is the size of the AxisAxisAxisaxisaxis dimension. Negative indices are interpreted by adding , i.e., 'index'"index""index""index""index" = 'index'"index""index""index""index" if 'index'"index""index""index""index" < 0.

Index Processing

Adjusting Axis

Negative values for AxisAxisAxisaxisaxis are made non-negative by adding the number of dimensions r of the input tensor:

Clamping Indices

Negative values in IndicesIndicesIndicesindicesindices are adjusted by adding the size s of the corresponding axis:

All values in IndicesIndicesIndicesindicesindices must satisfy Otherwise, an error will be raised.

The following generic parameters GenParamNameGenParamNameGenParamNamegenParamNamegen_param_name and the corresponding values GenParamValueGenParamValueGenParamValuegenParamValuegen_param_value are supported:

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

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

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

Certain parameters of layers created using this operator create_dl_layer_gathercreate_dl_layer_gatherCreateDlLayerGatherCreateDlLayerGathercreate_dl_layer_gather 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
'input_layer'"input_layer""input_layer""input_layer""input_layer" (DLLayerInputDLLayerInputDLLayerInputDLLayerInputdllayer_input,IndicesIndicesIndicesindicesindices) x
'name'"name""name""name""name" (LayerNameLayerNameLayerNamelayerNamelayer_name) x x
'axis'"axis""axis""axis""axis" (AxisAxisAxisaxisaxis) x
'output_layer'"output_layer""output_layer""output_layer""output_layer" (DLLayerGatherDLLayerGatherDLLayerGatherDLLayerGatherdllayer_gather) x
'shape'"shape""shape""shape""shape" 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 data input layer.

Default: 'DLLayerInput' "DLLayerInput" "DLLayerInput" "DLLayerInput" "DLLayerInput"

IndicesIndicesIndicesindicesindices (input_control)  number(-array) HTupleMaybeSequence[Union[int, HHandle]]HTupleHtuple (integer / handle) (int / long / HHandle) (Hlong / HHandle) (Hlong / handle)

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

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

Name of the output layer.

AxisAxisAxisaxisaxis (input_control)  number HTupleUnion[int, str]HTupleHtuple (integer / string) (int / long / string) (Hlong / HString) (Hlong / char*)

Axis along which to gather.

Default: 0

Suggested values: 0, 'batch'"batch""batch""batch""batch", 1, 'depth'"depth""depth""depth""depth", 2, 'height'"height""height""height""height", 3, 'width'"width""width""width""width"

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

Generic input parameter names.

Default: []

List of values: '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: 'true'"true""true""true""true", 'false'"false""false""false""false"

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

Output layer.

Module

Deep Learning Professional