create_dl_layer_loss_focalT_create_dl_layer_loss_focalCreateDlLayerLossFocalCreateDlLayerLossFocalcreate_dl_layer_loss_focal (Operator)
Name
create_dl_layer_loss_focalT_create_dl_layer_loss_focalCreateDlLayerLossFocalCreateDlLayerLossFocalcreate_dl_layer_loss_focal
— Create a focal loss layer.
Signature
create_dl_layer_loss_focal( : : DLLayerInput, DLLayerTarget, DLLayerWeights, DLLayerNormalization, LayerName, LossWeight, Gamma, ClassWeights, Type, GenParamName, GenParamValue : DLLayerLossFocal)
Herror T_create_dl_layer_loss_focal(const Htuple DLLayerInput, const Htuple DLLayerTarget, const Htuple DLLayerWeights, const Htuple DLLayerNormalization, const Htuple LayerName, const Htuple LossWeight, const Htuple Gamma, const Htuple ClassWeights, const Htuple Type, const Htuple GenParamName, const Htuple GenParamValue, Htuple* DLLayerLossFocal)
void CreateDlLayerLossFocal(const HTuple& DLLayerInput, const HTuple& DLLayerTarget, const HTuple& DLLayerWeights, const HTuple& DLLayerNormalization, const HTuple& LayerName, const HTuple& LossWeight, const HTuple& Gamma, const HTuple& ClassWeights, const HTuple& Type, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* DLLayerLossFocal)
HDlLayer HDlLayer::CreateDlLayerLossFocal(const HDlLayer& DLLayerTarget, const HDlLayer& DLLayerWeights, const HDlLayer& DLLayerNormalization, const HString& LayerName, const HTuple& LossWeight, const HTuple& Gamma, const HTuple& ClassWeights, const HString& Type, const HTuple& GenParamName, const HTuple& GenParamValue) const
HDlLayer HDlLayer::CreateDlLayerLossFocal(const HDlLayer& DLLayerTarget, const HDlLayer& DLLayerWeights, const HDlLayer& DLLayerNormalization, const HString& LayerName, double LossWeight, double Gamma, double ClassWeights, const HString& Type, const HString& GenParamName, const HString& GenParamValue) const
HDlLayer HDlLayer::CreateDlLayerLossFocal(const HDlLayer& DLLayerTarget, const HDlLayer& DLLayerWeights, const HDlLayer& DLLayerNormalization, const char* LayerName, double LossWeight, double Gamma, double ClassWeights, const char* Type, const char* GenParamName, const char* GenParamValue) const
HDlLayer HDlLayer::CreateDlLayerLossFocal(const HDlLayer& DLLayerTarget, const HDlLayer& DLLayerWeights, const HDlLayer& DLLayerNormalization, const wchar_t* LayerName, double LossWeight, double Gamma, double ClassWeights, const wchar_t* Type, const wchar_t* GenParamName, const wchar_t* GenParamValue) const
(
Windows only)
static void HOperatorSet.CreateDlLayerLossFocal(HTuple DLLayerInput, HTuple DLLayerTarget, HTuple DLLayerWeights, HTuple DLLayerNormalization, HTuple layerName, HTuple lossWeight, HTuple gamma, HTuple classWeights, HTuple type, HTuple genParamName, HTuple genParamValue, out HTuple DLLayerLossFocal)
HDlLayer HDlLayer.CreateDlLayerLossFocal(HDlLayer DLLayerTarget, HDlLayer DLLayerWeights, HDlLayer DLLayerNormalization, string layerName, HTuple lossWeight, HTuple gamma, HTuple classWeights, string type, HTuple genParamName, HTuple genParamValue)
HDlLayer HDlLayer.CreateDlLayerLossFocal(HDlLayer DLLayerTarget, HDlLayer DLLayerWeights, HDlLayer DLLayerNormalization, string layerName, double lossWeight, double gamma, double classWeights, string type, string genParamName, string genParamValue)
def create_dl_layer_loss_focal(dllayer_input: HHandle, dllayer_target: HHandle, dllayer_weights: HHandle, dllayer_normalization: HHandle, layer_name: str, loss_weight: Union[int, float], gamma: Union[int, float], class_weights: MaybeSequence[Union[int, float]], type: str, gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[str]) -> HHandle
Description
The operator create_dl_layer_loss_focalcreate_dl_layer_loss_focalCreateDlLayerLossFocalCreateDlLayerLossFocalcreate_dl_layer_loss_focal
creates a focal loss layer
whose handle is returned in DLLayerLossFocalDLLayerLossFocalDLLayerLossFocalDLLayerLossFocaldllayer_loss_focal
.
See the reference cited below for further
information about its definition and parameter meanings.
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 a overall loss weight if there are
multiple losses in the network.
The parameter GammaGammaGammagammagamma
is the exponent of the focal factor.
The parameter ClassWeightsClassWeightsClassWeightsclassWeightsclass_weights
defines class specific weights. All
loss contributions of foreground samples of a class are weighted with
the given factor. The background samples are weighted by 1 - ClassWeightsClassWeightsClassWeightsclassWeightsclass_weights
.
Typically, this is set to 1.0/(Number of samples of the class).
Note, the length of this array has to be either 1, then its broadcasted
to the number of classes, or it has to correspond to the number of classes.
The default value [] corresponds to a factor of 0.5 for
all classes.
Note, if the number of classes are changed on a network then the number of
class specific weights are also adapted and reset with the default value
0.5 for each class.
The parameter TypeTypeTypetypetype
sets the focal loss options:
- 'focal_binary'"focal_binary""focal_binary""focal_binary""focal_binary":
Focal loss.
- 'sigmoid_focal_binary'"sigmoid_focal_binary""sigmoid_focal_binary""sigmoid_focal_binary""sigmoid_focal_binary":
Focal loss fused with sigmoid.
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"
Certain parameters of layers created using this operator
create_dl_layer_loss_focalcreate_dl_layer_loss_focalCreateDlLayerLossFocalCreateDlLayerLossFocalcreate_dl_layer_loss_focal
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
.
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)
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.
DLLayerNormalizationDLLayerNormalizationDLLayerNormalizationDLLayerNormalizationdllayer_normalization
(input_control) dl_layer →
HDlLayer, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Normalization layer.
Default:
[]
LayerNameLayerNameLayerNamelayerNamelayer_name
(input_control) string →
HTuplestrHTupleHtuple (string) (string) (HString) (char*)
Name of the output layer.
LossWeightLossWeightLossWeightlossWeightloss_weight
(input_control) number →
HTupleUnion[int, float]HTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)
Overall loss weight if there are multiple losses in the
network.
Default:
1.0
GammaGammaGammagammagamma
(input_control) number →
HTupleUnion[int, float]HTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)
Exponent of the focal factor.
Default:
2.0
ClassWeightsClassWeightsClassWeightsclassWeightsclass_weights
(input_control) number(-array) →
HTupleMaybeSequence[Union[int, float]]HTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)
Class specific weight.
Default:
[]
TypeTypeTypetypetype
(input_control) string →
HTuplestrHTupleHtuple (string) (string) (HString) (char*)
Focal loss type.
Default:
'focal_binary'
"focal_binary"
"focal_binary"
"focal_binary"
"focal_binary"
List of values:
'focal_binary'"focal_binary""focal_binary""focal_binary""focal_binary", 'sigmoid_focal_binary'"sigmoid_focal_binary""sigmoid_focal_binary""sigmoid_focal_binary""sigmoid_focal_binary"
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[str]HTupleHtuple (string) (string) (HString) (char*)
Generic input parameter values.
Default:
[]
Suggested values:
'true'"true""true""true""true", 'false'"false""false""false""false"
DLLayerLossFocalDLLayerLossFocalDLLayerLossFocalDLLayerLossFocaldllayer_loss_focal
(output_control) dl_layer →
HDlLayer, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Focal loss layer.
References
T. Lin, P. Goyal, R. Girshick, K. He and P. Dollar,
"Focal Loss for Dense Object Detection," in IEEE Transactions on Pattern
Analysis and Machine Intelligence, vol. 42, no. 2, pp. 318-327, 1 Feb. 2020,
doi: 10.1109/TPAMI.2018.2858826.
Module
Deep Learning Training