create_dl_layer_loss_distanceπ
Short descriptionπ
create_dl_layer_loss_distance β Create a distance loss layer.
Signatureπ
create_dl_layer_loss_distance( dl_layer DLLayerInput, dl_layer DLLayerTarget, dl_layer DLLayerWeights, string LayerName, string DistanceType, number LossWeight, attribute.name GenParamName, attribute.value GenParamValue, out dl_layer DLLayerLossDistance )
Descriptionπ
The operator create_dl_layer_loss_distance creates a distance loss
layer whose handle is returned in DLLayerLossDistance.
This layer expects multiple layers as input:
-
DLLayerInput: Specifies the prediction (e.g., a softmax layer). -
DLLayerTarget: Specifies the target sequences (originating from the ground truth information). -
DLLayerWeights: Specifies the weight sequences. This parameter is optional. If an empty tuple [] is passed for all values the weighting factor 1.0 is used.
The parameter LayerName sets an individual layer name.
Note that if creating a model using create_dl_model each layer of
the created network must have a unique name.
The parameter LossWeight is an overall loss weight if there are
multiple losses in the network.
The parameter DistanceType determines which distance measure is
applied. Currently, 'l2' and 'l1' are implemented.
Depending on the generic parameter 'reduce' this results in
-
L2 loss distance as a tensor:
\[\begin{eqnarray*} \textrm{DLLayerLossDistance}[i] &=& 0.5 \cdot \textrm{LossWeight} \cdot \textrm{DLLayerWeights}[i]\\ &~& \cdot (\textrm{DLLayerInput}[i] - \textrm{DLLayerTarget}[i])^{2}, \end{eqnarray*}\]in this case loss is the tensor of the same size as
DLLayerInput. -
L2 loss distance as a scalar:
\[\begin{eqnarray*} \textrm{DLLayerLossDistance} = \frac{\sum_{i=0}^{N-1} \textrm{DLLayerLossDistance}[i]} {\sum_{i=0}^{N-1} \textrm{DLLayerWeights}[i]}, \end{eqnarray*}\]where \(N\) is a number of elements in
DLLayerInput. -
L1 loss distance as a tensor:
\[\begin{eqnarray*} \textrm{DLLayerLossDistance}[i] &=& \textrm{LossWeight} \cdot \textrm{DLLayerWeights}[i]\\ &~& \cdot |\textrm{DLLayerInput}[i] - \textrm{DLLayerTarget}[i]|, \end{eqnarray*}\]in this case loss is the tensor of the same size as
DLLayerInput. -
L1 loss distance as a scalar:
\[\begin{eqnarray*} \textrm{DLLayerLossDistance} = \frac{\sum_{i=0}^{N-1} \textrm{DLLayerLossDistance}[i]} {\sum_{i=0}^{N-1} \textrm{DLLayerWeights}[i]}, \end{eqnarray*}\]where \(N\) is a number of elements in
DLLayerInput.
Thus DLLayerInput, DLLayerTarget and
DLLayerWeights should have the same size. Setting the weights in
DLLayerWeights to 1 will result in a loss normalized over
the number of elements.
The following generic parameters GenParamName and the corresponding
values GenParamValue are supported:
-
'is_inference_output': Determines whether
apply_dl_modelwill include the output of this layer in the dictionaryDLResultBatcheven without specifying this layer inOutputs('true') or not ('false').Default: 'false'
-
'reduce': Determines whether the output of the layer is reduced:
-
'true': The output is reduced to a scalar.
-
'false': The output of the layer is a tensor, where each element is a βper-pixelβ loss (squared differences).
Default: 'true'.
-
Certain parameters of layers created using this operator
create_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_param and which ones can be retrieved
using get_dl_model_layer_param or get_dl_layer_param.
Note, the operators set_dl_model_layer_param and
get_dl_model_layer_param require a model created by
create_dl_model.
| Layer Parameters | set |
get |
|---|---|---|
'input_layer' (DLLayerInput, DLLayerTarget, and/or DLLayerWeights) |
x |
|
'loss_weight' (LossWeight) |
x |
x |
'name' (LayerName) |
x |
x |
'output_layer' (DLLayerLossDistance) |
x |
|
| 'shape' | x |
|
| 'type' | x |
|
'distance_type' (DistanceType) |
x |
| Generic Layer Parameters | set |
get |
|---|---|---|
| 'is_inference_output' | x |
x |
| 'num_trainable_params' | x |
|
| 'reduce' | x |
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π
DLLayerInput (input_control) dl_layer β (handle)
Input layer.
DLLayerTarget (input_control) dl_layer β (handle)
Target layer.
DLLayerWeights (input_control) dl_layer β (handle)
Weights layer.
LayerName (input_control) string β (string)
Name of the output layer.
DistanceType (input_control) string β (string)
Type of distance.
Default: 'l2'
List of values: 'l1', 'l2'
LossWeight (input_control) number β (real)
Loss weight. Applies to all losses, if several losses occur in the network.
Default: 1.0
GenParamName (input_control) attribute.name(-array) β (string)
Generic input parameter names.
Default: []
List of values: 'is_inference_output', 'reduce'
GenParamValue (input_control) attribute.value(-array) β (string)
Generic input parameter values.
Default: []
Suggested values: 'true', 'false'
DLLayerLossDistance (output_control) dl_layer β (handle)
Distance loss layer.
Moduleπ
Deep Learning Professional