create_dl_layer_loss_distanceT_create_dl_layer_loss_distanceCreateDlLayerLossDistanceCreateDlLayerLossDistancecreate_dl_layer_loss_distance创建深度学习层损失距离(算子)

名称

create_dl_layer_loss_distanceT_create_dl_layer_loss_distanceCreateDlLayerLossDistanceCreateDlLayerLossDistancecreate_dl_layer_loss_distance — 创建距离损失层。

签名

create_dl_layer_loss_distance( : : DLLayerInput, DLLayerTarget, DLLayerWeights, LayerName, DistanceType, LossWeight, GenParamName, GenParamValue : DLLayerLossDistance)

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)

static void HOperatorSet.CreateDlLayerLossDistance(HTuple DLLayerInput, HTuple DLLayerTarget, HTuple DLLayerWeights, HTuple layerName, HTuple distanceType, HTuple lossWeight, HTuple genParamName, HTuple genParamValue, out HTuple DLLayerLossDistance)

HDlLayer HDlLayer.CreateDlLayerLossDistance(HDlLayer DLLayerTarget, HDlLayer DLLayerWeights, string layerName, string distanceType, double lossWeight, HTuple genParamName, HTuple genParamValue)

HDlLayer HDlLayer.CreateDlLayerLossDistance(HDlLayer DLLayerTarget, HDlLayer DLLayerWeights, string layerName, string distanceType, double lossWeight, string genParamName, string genParamValue)

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

描述

算子 create_dl_layer_loss_distancecreate_dl_layer_loss_distanceCreateDlLayerLossDistanceCreateDlLayerLossDistanceCreateDlLayerLossDistancecreate_dl_layer_loss_distance 创建一个距离损失层,其句柄通过 DLLayerLossDistanceDLLayerLossDistanceDLLayerLossDistanceDLLayerLossDistanceDLLayerLossDistancedllayer_loss_distance 返回。

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

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

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

参数 DistanceTypeDistanceTypeDistanceTypeDistanceTypedistanceTypedistance_type 决定采用哪种距离度量方法。当前仅实现 'l2'"l2""l2""l2""l2""l2" 选项。根据泛型参数 'reduce'"reduce""reduce""reduce""reduce""reduce" 的值,结果如下

因此,DLLayerInputDLLayerInputDLLayerInputDLLayerInputDLLayerInputdllayer_inputDLLayerTargetDLLayerTargetDLLayerTargetDLLayerTargetDLLayerTargetdllayer_targetDLLayerWeightsDLLayerWeightsDLLayerWeightsDLLayerWeightsDLLayerWeightsdllayer_weights 应具有相同大小。将 DLLayerWeightsDLLayerWeightsDLLayerWeightsDLLayerWeightsDLLayerWeightsdllayer_weights 中的权重设置为 1 将导致损失被元素数量进行归一化。

支持以下泛型参数 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"

'reduce'"reduce""reduce""reduce""reduce""reduce"

决定该层的输出是否被缩减:

  • 'true'"true""true""true""true""true":输出被缩减为标量。

  • 'false'"false""false""false""false""false":该层的输出为张量,其中每个元素表示“每像素”的损失(平方差)。

默认值: 'true'"true""true""true""true""true"

使用 create_dl_layer_loss_distancecreate_dl_layer_loss_distanceCreateDlLayerLossDistanceCreateDlLayerLossDistanceCreateDlLayerLossDistancecreate_dl_layer_loss_distance 算子创建的层,其特定参数可通过其他算子进行设置与检索。下表概述了可通过 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 创建的模型。

层参数 设置 获取
'input_layer'"input_layer""input_layer""input_layer""input_layer""input_layer" (DLLayerInputDLLayerInputDLLayerInputDLLayerInputDLLayerInputdllayer_input, DLLayerTargetDLLayerTargetDLLayerTargetDLLayerTargetDLLayerTargetdllayer_target 和/或 DLLayerWeightsDLLayerWeightsDLLayerWeightsDLLayerWeightsDLLayerWeightsdllayer_weights)
'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" (DLLayerLossDistanceDLLayerLossDistanceDLLayerLossDistanceDLLayerLossDistanceDLLayerLossDistancedllayer_loss_distance)
'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"
'reduce'"reduce""reduce""reduce""reduce""reduce"

执行信息

参数

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)

权重层。

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

输出层的名称。

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

距离类型。

默认值: 'l2' "l2" "l2" "l2" "l2" "l2"

值列表: 'l2'"l2""l2""l2""l2""l2"

LossWeightLossWeightLossWeightLossWeightlossWeightloss_weight (输入控制)  number HTuplefloatHTupleHtuple (real) (double) (double) (double)

损失权重。适用于所有损失,若网络中存在多个损失。

默认值: 1.0

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

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"

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

距离损失层。

模块

深度学习训练