create_dl_layer_loss_focalT_create_dl_layer_loss_focalCreateDlLayerLossFocalCreateDlLayerLossFocalcreate_dl_layer_loss_focal创建深度学习层损失焦点(算子)

名称

create_dl_layer_loss_focalT_create_dl_layer_loss_focalCreateDlLayerLossFocalCreateDlLayerLossFocalcreate_dl_layer_loss_focal — 创建焦点损失层。

签名

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

描述

算子 create_dl_layer_loss_focalcreate_dl_layer_loss_focalCreateDlLayerLossFocalCreateDlLayerLossFocalCreateDlLayerLossFocalcreate_dl_layer_loss_focal 创建一个焦点损失层,其句柄通过 DLLayerLossFocalDLLayerLossFocalDLLayerLossFocalDLLayerLossFocalDLLayerLossFocaldllayer_loss_focal 返回。有关其定义和参数含义的详细信息,请参阅下方引用的参考资料。

该层期望接收多个层作为输入:

参数 LayerNameLayerNameLayerNameLayerNamelayerNamelayer_name 用于设置单个层的名称。请注意,若使用 create_dl_modelcreate_dl_modelCreateDlModelCreateDlModelCreateDlModelcreate_dl_model 创建模型,则创建网络中的每个层必须具有唯一名称。

参数 LossWeightLossWeightLossWeightLossWeightlossWeightloss_weight 是网络中存在多个损失函数时的整体损失权重。

参数 GammaGammaGammaGammagammagamma 是焦点因子(focal factor)的指数。

参数 ClassWeightsClassWeightsClassWeightsClassWeightsclassWeightsclass_weights 定义了类特有的权重。某类的所有损失贡献均按给定因子加权。通常该值设为 1.0/(该类样本数量)。注意:此数组长度必须与类别数量一致。默认值 [] 表示所有类别均采用 1.0 因子。

参数 TypeTypeTypeTypetypetype 置焦点损失选项:

'focal_binary'"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""sigmoid_focal_binary"

焦点损失与 sigmoid 函数融合。

支持以下泛型参数 GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name 及其对应值 GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value

'is_inference_output'"is_inference_output""is_inference_output""is_inference_output""is_inference_output""is_inference_output"

确定 apply_dl_modelapply_dl_modelApplyDlModelApplyDlModelApplyDlModelapply_dl_model 是否将此层的输出包含在字典 DLResultBatchDLResultBatchDLResultBatchDLResultBatchDLResultBatchdlresult_batch 中,即使未在 OutputsOutputsOutputsOutputsoutputsoutputs 中指定此层('true'"true""true""true""true""true")或不包含('false'"false""false""false""false""false")。

默认值: 'false'"false""false""false""false""false"

使用 create_dl_layer_loss_focalcreate_dl_layer_loss_focalCreateDlLayerLossFocalCreateDlLayerLossFocalCreateDlLayerLossFocalcreate_dl_layer_loss_focal 算子创建的层,其特定参数可通过其他算子进行设置与检索。下表概述了可通过 set_dl_model_layer_paramset_dl_model_layer_paramSetDlModelLayerParamSetDlModelLayerParamSetDlModelLayerParamset_dl_model_layer_param 设置的参数,以及可通过 get_dl_model_layer_paramget_dl_model_layer_paramGetDlModelLayerParamGetDlModelLayerParamGetDlModelLayerParamget_dl_model_layer_paramget_dl_layer_paramget_dl_layer_paramGetDlLayerParamGetDlLayerParamGetDlLayerParamget_dl_layer_param 检索的参数。请注意,算子 set_dl_model_layer_paramset_dl_model_layer_paramSetDlModelLayerParamSetDlModelLayerParamSetDlModelLayerParamset_dl_model_layer_paramget_dl_model_layer_paramget_dl_model_layer_paramGetDlModelLayerParamGetDlModelLayerParamGetDlModelLayerParamget_dl_model_layer_param 需基于 create_dl_modelcreate_dl_modelCreateDlModelCreateDlModelCreateDlModelcreate_dl_model 创建的模型。

层参数 设置 获取
'focal_type'"focal_type""focal_type""focal_type""focal_type""focal_type" (TypeTypeTypeTypetypetype)
'gamma'"gamma""gamma""gamma""gamma""gamma" (GammaGammaGammaGammagammagamma)
'input_layer'"input_layer""input_layer""input_layer""input_layer""input_layer" (DLLayerInputDLLayerInputDLLayerInputDLLayerInputDLLayerInputdllayer_input, DLLayerTargetDLLayerTargetDLLayerTargetDLLayerTargetDLLayerTargetdllayer_target, DLLayerWeightsDLLayerWeightsDLLayerWeightsDLLayerWeightsDLLayerWeightsdllayer_weights 和/或 DLLayerNormalizationDLLayerNormalizationDLLayerNormalizationDLLayerNormalizationDLLayerNormalizationdllayer_normalization)
'loss_weight'"loss_weight""loss_weight""loss_weight""loss_weight""loss_weight" (LossWeightLossWeightLossWeightLossWeightlossWeightloss_weight)
'name'"name""name""name""name""name" (LayerNameLayerNameLayerNameLayerNamelayerNamelayer_name)
'output_layer'"output_layer""output_layer""output_layer""output_layer""output_layer" (DLLayerLossFocalDLLayerLossFocalDLLayerLossFocalDLLayerLossFocalDLLayerLossFocaldllayer_loss_focal)
'shape'"shape""shape""shape""shape""shape"
'type'"type""type""type""type""type"
泛型层参数 设置 获取
'is_inference_output'"is_inference_output""is_inference_output""is_inference_output""is_inference_output""is_inference_output"
'num_trainable_params'"num_trainable_params""num_trainable_params""num_trainable_params""num_trainable_params""num_trainable_params"

执行信息

参数

DLLayerInputDLLayerInputDLLayerInputDLLayerInputDLLayerInputdllayer_input (输入控制)  dl_layer HDlLayer, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

输入层。

DLLayerTargetDLLayerTargetDLLayerTargetDLLayerTargetDLLayerTargetdllayer_target (输入控制)  dl_layer HDlLayer, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

目标层。

DLLayerWeightsDLLayerWeightsDLLayerWeightsDLLayerWeightsDLLayerWeightsdllayer_weights (输入控制)  dl_layer HDlLayer, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

权重层。

DLLayerNormalizationDLLayerNormalizationDLLayerNormalizationDLLayerNormalizationDLLayerNormalizationdllayer_normalization (输入控制)  dl_layer HDlLayer, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

归一化层。

默认值: []

LayerNameLayerNameLayerNameLayerNamelayerNamelayer_name (输入控制)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

输出层的名称。

LossWeightLossWeightLossWeightLossWeightlossWeightloss_weight (输入控制)  number HTupleUnion[int, float]HTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)

若网络中存在多个损失,则为总体损失权重。

默认值: 1.0

GammaGammaGammaGammagammagamma (输入控制)  number HTupleUnion[int, float]HTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)

焦点因子的指数。

默认值: 2.0

ClassWeightsClassWeightsClassWeightsClassWeightsclassWeightsclass_weights (输入控制)  number(-array) HTupleMaybeSequence[Union[int, float]]HTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)

类特有的权重。

默认值: []

TypeTypeTypeTypetypetype (输入控制)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

焦点损失类型。

默认值: 'focal_binary' "focal_binary" "focal_binary" "focal_binary" "focal_binary" "focal_binary"

值列表: 'focal_binary'"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""sigmoid_focal_binary"

GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name (输入控制)  attribute.name(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

泛型输入参数名称。

默认值: []

值列表: 'is_inference_output'"is_inference_output""is_inference_output""is_inference_output""is_inference_output""is_inference_output"

GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value (输入控制)  attribute.value(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

泛型输入参数值。

默认值: []

建议值: 'true'"true""true""true""true""true", 'false'"false""false""false""false""false"

DLLayerLossFocalDLLayerLossFocalDLLayerLossFocalDLLayerLossFocalDLLayerLossFocaldllayer_loss_focal (输出控制)  dl_layer HDlLayer, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

焦点损失层。

参考文献

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.

模块

深度学习训练