create_dl_layer_elementwiseT_create_dl_layer_elementwiseCreateDlLayerElementwiseCreateDlLayerElementwisecreate_dl_layer_elementwise创建深度学习层元素级(算子)

名称

create_dl_layer_elementwiseT_create_dl_layer_elementwiseCreateDlLayerElementwiseCreateDlLayerElementwisecreate_dl_layer_elementwise — 创建元素级层。

签名

create_dl_layer_elementwise( : : DLLayerInputs, LayerName, Operation, Coefficients, GenParamName, GenParamValue : DLLayerElementWise)

Herror T_create_dl_layer_elementwise(const Htuple DLLayerInputs, const Htuple LayerName, const Htuple Operation, const Htuple Coefficients, const Htuple GenParamName, const Htuple GenParamValue, Htuple* DLLayerElementWise)

void CreateDlLayerElementwise(const HTuple& DLLayerInputs, const HTuple& LayerName, const HTuple& Operation, const HTuple& Coefficients, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* DLLayerElementWise)

static HDlLayer HDlLayer::CreateDlLayerElementwise(const HDlLayerArray& DLLayerInputs, const HString& LayerName, const HString& Operation, const HTuple& Coefficients, const HTuple& GenParamName, const HTuple& GenParamValue)

HDlLayer HDlLayer::CreateDlLayerElementwise(const HString& LayerName, const HString& Operation, double Coefficients, const HString& GenParamName, const HString& GenParamValue) const

HDlLayer HDlLayer::CreateDlLayerElementwise(const char* LayerName, const char* Operation, double Coefficients, const char* GenParamName, const char* GenParamValue) const

HDlLayer HDlLayer::CreateDlLayerElementwise(const wchar_t* LayerName, const wchar_t* Operation, double Coefficients, const wchar_t* GenParamName, const wchar_t* GenParamValue) const   ( Windows only)

static void HOperatorSet.CreateDlLayerElementwise(HTuple DLLayerInputs, HTuple layerName, HTuple operation, HTuple coefficients, HTuple genParamName, HTuple genParamValue, out HTuple DLLayerElementWise)

static HDlLayer HDlLayer.CreateDlLayerElementwise(HDlLayer[] DLLayerInputs, string layerName, string operation, HTuple coefficients, HTuple genParamName, HTuple genParamValue)

HDlLayer HDlLayer.CreateDlLayerElementwise(string layerName, string operation, double coefficients, string genParamName, string genParamValue)

def create_dl_layer_elementwise(dllayer_inputs: MaybeSequence[HHandle], layer_name: str, operation: str, coefficients: MaybeSequence[float], gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[Union[int, float, str]]) -> HHandle

描述

算子 create_dl_layer_elementwisecreate_dl_layer_elementwiseCreateDlLayerElementwiseCreateDlLayerElementwiseCreateDlLayerElementwisecreate_dl_layer_elementwise 创建一个元素级(逐元素)层,其句柄通过 DLLayerElementWiseDLLayerElementWiseDLLayerElementWiseDLLayerElementWiseDLLayerElementWisedllayer_element_wise 返回。

元素级层对输入层句柄中的每个数据张量及其所有元素应用特定操作。因此,所有输入数据张量应具有相同形状,且输出张量的形状与第一个输入张量相同。

参数 DLLayerInputsDLLayerInputsDLLayerInputsDLLayerInputsDLLayerInputsdllayer_inputs 决定输入层的数量。该层期望接收多个层作为输入。

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

参数 OperationOperationOperationOperationoperationoperation 指定所应用的运算类型。根据 OperationOperationOperationOperationoperationoperation,该层支持隐式广播。即当第二个或后续输入张量的形状维度(batch_sizedepthheightwidth)中有任意一个为 1 时,系统会沿该维度隐式进行值乘运算,使输入张量形状匹配第一个输入。支持的取值为:

可选参数 CoefficientsCoefficientsCoefficientsCoefficientscoefficientscoefficients 为每个输入张量确定权重系数。CoefficientsCoefficientsCoefficientsCoefficientscoefficientscoefficients 中值的数量必须与 DLLayerInputsDLLayerInputsDLLayerInputsDLLayerInputsDLLayerInputsdllayer_inputs 中馈入层的数量匹配。若元素级运算中无需使用权重系数,则将 CoefficientsCoefficientsCoefficientsCoefficientscoefficientscoefficients 设为 []

限制:OperationOperationOperationOperationoperationoperation = 'product'"product""product""product""product""product" 时,不得设置系数。

示例: 对于 OperationOperationOperationOperationoperationoperation = 'sum'"sum""sum""sum""sum""sum",输出数据张量的第 个元素由以下公式给出: 其中 为输入数据张量的数量。

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

层参数 设置 获取
'coefficients'"coefficients""coefficients""coefficients""coefficients""coefficients" (CoefficientsCoefficientsCoefficientsCoefficientscoefficientscoefficients)
'input_layer'"input_layer""input_layer""input_layer""input_layer""input_layer" (DLLayerInputsDLLayerInputsDLLayerInputsDLLayerInputsDLLayerInputsdllayer_inputs)
'name'"name""name""name""name""name" (LayerNameLayerNameLayerNameLayerNamelayerNamelayer_name)
'operation'"operation""operation""operation""operation""operation" (OperationOperationOperationOperationoperationoperation)
'output_layer'"output_layer""output_layer""output_layer""output_layer""output_layer" (DLLayerElementWiseDLLayerElementWiseDLLayerElementWiseDLLayerElementWiseDLLayerElementWisedllayer_element_wise)
'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"

执行信息

参数

DLLayerInputsDLLayerInputsDLLayerInputsDLLayerInputsDLLayerInputsdllayer_inputs (输入控制)  dl_layer(-array) HDlLayer, HTupleMaybeSequence[HHandle]HTupleHtuple (handle) (IntPtr) (HHandle) (handle)

输入层的数量。

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

输出层的名称。

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

元素级(逐元素)运算。

默认值: 'sum' "sum" "sum" "sum" "sum" "sum"

值列表: 'maximum'"maximum""maximum""maximum""maximum""maximum", 'minimum'"minimum""minimum""minimum""minimum""minimum", 'product'"product""product""product""product""product", 'sum'"sum""sum""sum""sum""sum"

CoefficientsCoefficientsCoefficientsCoefficientscoefficientscoefficients (输入控制)  number(-array) HTupleMaybeSequence[float]HTupleHtuple (real) (double) (double) (double)

可选输入张量系数。

默认值: []

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[Union[int, float, str]]HTupleHtuple (string / integer / real) (string / int / long / double) (HString / Hlong / double) (char* / Hlong / double)

泛型输入参数值。

默认值: []

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

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

元素级层。

模块

深度学习训练