Operator Reference

create_dl_layer_loss_distanceT_create_dl_layer_loss_distanceCreateDlLayerLossDistanceCreateDlLayerLossDistancecreate_dl_layer_loss_distance (Operator)

create_dl_layer_loss_distanceT_create_dl_layer_loss_distanceCreateDlLayerLossDistanceCreateDlLayerLossDistancecreate_dl_layer_loss_distance — Create a distance loss layer.

Signature

Herror T_create_dl_layer_loss_distance(const Htuple DLLayerInput, const Htuple DLLayerTarget, const Htuple DLLayerWeights, const Htuple LayerName, const Htuple DistanceType, const Htuple LossWeight, const Htuple GenParamName, const Htuple GenParamValue, Htuple* DLLayerLossDistance)

void CreateDlLayerLossDistance(const HTuple& DLLayerInput, const HTuple& DLLayerTarget, const HTuple& DLLayerWeights, const HTuple& LayerName, const HTuple& DistanceType, const HTuple& LossWeight, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* DLLayerLossDistance)

HDlLayer HDlLayer::CreateDlLayerLossDistance(const HDlLayer& DLLayerTarget, const HDlLayer& DLLayerWeights, const HString& LayerName, const HString& DistanceType, double LossWeight, const HTuple& GenParamName, const HTuple& GenParamValue) const

HDlLayer HDlLayer::CreateDlLayerLossDistance(const HDlLayer& DLLayerTarget, const HDlLayer& DLLayerWeights, const HString& LayerName, const HString& DistanceType, double LossWeight, const HString& GenParamName, const HString& GenParamValue) const

HDlLayer HDlLayer::CreateDlLayerLossDistance(const HDlLayer& DLLayerTarget, const HDlLayer& DLLayerWeights, const char* LayerName, const char* DistanceType, double LossWeight, const char* GenParamName, const char* GenParamValue) const

HDlLayer HDlLayer::CreateDlLayerLossDistance(const HDlLayer& DLLayerTarget, const HDlLayer& DLLayerWeights, const wchar_t* LayerName, const wchar_t* DistanceType, double LossWeight, const wchar_t* GenParamName, const wchar_t* GenParamValue) const   ( Windows only)

def create_dl_layer_loss_distance(dllayer_input: HHandle, dllayer_target: HHandle, dllayer_weights: HHandle, layer_name: str, distance_type: str, loss_weight: float, gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[str]) -> HHandle

Description

The operator create_dl_layer_loss_distancecreate_dl_layer_loss_distanceCreateDlLayerLossDistanceCreateDlLayerLossDistancecreate_dl_layer_loss_distance creates a distance loss layer whose handle is returned in DLLayerLossDistanceDLLayerLossDistanceDLLayerLossDistanceDLLayerLossDistancedllayer_loss_distance.

This layer expects multiple layers as input:

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.

The parameter LossWeightLossWeightLossWeightlossWeightloss_weight is an overall loss weight if there are multiple losses in the network.

The parameter DistanceTypeDistanceTypeDistanceTypedistanceTypedistance_type determines which distance measure is applied. Currently, 'l2'"l2""l2""l2""l2" and 'l1'"l1""l1""l1""l1" are implemented. Depending on the generic parameter 'reduce'"reduce""reduce""reduce""reduce" this results in

Thus DLLayerInputDLLayerInputDLLayerInputDLLayerInputdllayer_input, DLLayerTargetDLLayerTargetDLLayerTargetDLLayerTargetdllayer_target and DLLayerWeightsDLLayerWeightsDLLayerWeightsDLLayerWeightsdllayer_weights should have the same size. Setting the weights in DLLayerWeightsDLLayerWeightsDLLayerWeightsDLLayerWeightsdllayer_weights to 1 will result in a loss normalized over the number of elements.

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

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

'reduce'"reduce""reduce""reduce""reduce":

Determines whether the output of the layer is reduced:

  • 'true'"true""true""true""true": The output is reduced to a scalar.

  • 'false'"false""false""false""false": The output of the layer is a tensor, where each element is a 'per-pixel' loss (squared differences).

Default: 'true'"true""true""true""true".

Certain parameters of layers created using this operator create_dl_layer_loss_distancecreate_dl_layer_loss_distanceCreateDlLayerLossDistanceCreateDlLayerLossDistancecreate_dl_layer_loss_distance 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, DLLayerTargetDLLayerTargetDLLayerTargetDLLayerTargetdllayer_target, and/or DLLayerWeightsDLLayerWeightsDLLayerWeightsDLLayerWeightsdllayer_weights) x
'loss_weight'"loss_weight""loss_weight""loss_weight""loss_weight" (LossWeightLossWeightLossWeightlossWeightloss_weight) x x
'name'"name""name""name""name" (LayerNameLayerNameLayerNamelayerNamelayer_name) x x
'output_layer'"output_layer""output_layer""output_layer""output_layer" (DLLayerLossDistanceDLLayerLossDistanceDLLayerLossDistanceDLLayerLossDistancedllayer_loss_distance) x
'shape'"shape""shape""shape""shape" x
'type'"type""type""type""type" x
'distance_type'"distance_type""distance_type""distance_type""distance_type" (DistanceTypeDistanceTypeDistanceTypedistanceTypedistance_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
'reduce'"reduce""reduce""reduce""reduce" x 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)

Input layer.

DLLayerTargetDLLayerTargetDLLayerTargetDLLayerTargetdllayer_target (input_control)  dl_layer HDlLayer, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Target layer.

DLLayerWeightsDLLayerWeightsDLLayerWeightsDLLayerWeightsdllayer_weights (input_control)  dl_layer HDlLayer, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Weights layer.

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

Name of the output layer.

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

Type of distance.

Default: 'l2' "l2" "l2" "l2" "l2"

List of values: 'l1'"l1""l1""l1""l1", 'l2'"l2""l2""l2""l2"

LossWeightLossWeightLossWeightlossWeightloss_weight (input_control)  number HTuplefloatHTupleHtuple (real) (double) (double) (double)

Loss weight. Applies to all losses, if several losses occur in the network.

Default: 1.0

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", 'reduce'"reduce""reduce""reduce""reduce"

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

Generic input parameter values.

Default: []

Suggested values: 'true'"true""true""true""true", 'false'"false""false""false""false"

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

Distance loss layer.

Module

Deep Learning Professional