create_dl_layer_softmaxT_create_dl_layer_softmaxCreateDlLayerSoftmaxCreateDlLayerSoftmaxcreate_dl_layer_softmax创建深度学习层软最大化(算子)
名称
create_dl_layer_softmaxT_create_dl_layer_softmaxCreateDlLayerSoftmaxCreateDlLayerSoftmaxcreate_dl_layer_softmax — 创建软最大化层。
签名
void CreateDlLayerSoftmax(const HTuple& DLLayerInput, const HTuple& LayerName, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* DLLayerSoftMax)
HDlLayer HDlLayer::CreateDlLayerSoftmax(const HString& LayerName, const HTuple& GenParamName, const HTuple& GenParamValue) const
HDlLayer HDlLayer::CreateDlLayerSoftmax(const HString& LayerName, const HString& GenParamName, const HString& GenParamValue) const
HDlLayer HDlLayer::CreateDlLayerSoftmax(const char* LayerName, const char* GenParamName, const char* GenParamValue) const
HDlLayer HDlLayer::CreateDlLayerSoftmax(const wchar_t* LayerName, const wchar_t* GenParamName, const wchar_t* GenParamValue) const
(
Windows only)
描述
算子 create_dl_layer_softmaxcreate_dl_layer_softmaxCreateDlLayerSoftmaxCreateDlLayerSoftmaxCreateDlLayerSoftmaxcreate_dl_layer_softmax 创建一个软最大化层,其句柄通过 DLLayerSoftMaxDLLayerSoftMaxDLLayerSoftMaxDLLayerSoftMaxDLLayerSoftMaxdllayer_soft_max 返回。
参数 DLLayerInputDLLayerInputDLLayerInputDLLayerInputDLLayerInputdllayer_input 确定输入层,并期望层句柄作为值。
参数 LayerNameLayerNameLayerNameLayerNamelayerNamelayer_name 用于设置单个层的名称。请注意,若使用 create_dl_modelcreate_dl_modelCreateDlModelCreateDlModelCreateDlModelcreate_dl_model 创建模型,则创建网络中的每个层必须具有唯一名称。
软最大层对每个输入
应用如下定义的软最大化函数:
其中 为输入数量。训练过程中,软最大化函数的结果会通过对数函数进行转换,使输出值适合作为交叉熵损失层等模块的输入。此行为可通过设置泛型参数
'output_mode'"output_mode""output_mode""output_mode""output_mode""output_mode" 进行调整,详见下文说明。
支持以下泛型参数 GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name 及其对应值 GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value:
- 'output_mode'"output_mode""output_mode""output_mode""output_mode""output_mode":
-
此参数决定输出是否以及在何种情况下通过对数函数进行转换:
-
'default'"default""default""default""default""default":推理过程中直接返回 softmax 函数结果作为输出;训练过程中,softmax 结果会进一步通过对数函数进行转换。
-
'no_log_training'"no_log_training""no_log_training""no_log_training""no_log_training""no_log_training":训练过程中 softmax 函数结果不进行对数转换。
-
'log_inference'"log_inference""log_inference""log_inference""log_inference""log_inference":推理阶段计算 softmax 的对数,与训练阶段方式一致。
默认值: 'default'"default""default""default""default""default"。
- '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_softmaxcreate_dl_layer_softmaxCreateDlLayerSoftmaxCreateDlLayerSoftmaxCreateDlLayerSoftmaxcreate_dl_layer_softmax 算子创建的层,其特定参数可通过其他算子进行设置与检索。下表概述了可通过 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_param 或 get_dl_layer_paramget_dl_layer_paramGetDlLayerParamGetDlLayerParamGetDlLayerParamget_dl_layer_param 检索的参数。请注意,算子 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_param
需基于 create_dl_modelcreate_dl_modelCreateDlModelCreateDlModelCreateDlModelcreate_dl_model 创建的模型。
|
泛型层参数 |
设置 |
获取 |
|
'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" |
|
|
|
'output_mode'"output_mode""output_mode""output_mode""output_mode""output_mode" |
|
|
执行信息
- 多线程类型:可重入(与非独占算子并行运行)。
- 多线程作用域:全局(可从任何线程调用)。
- 未采用并行化处理。
参数
DLLayerInputDLLayerInputDLLayerInputDLLayerInputDLLayerInputdllayer_input (输入控制) dl_layer → HDlLayer, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
输入层。
LayerNameLayerNameLayerNameLayerNamelayerNamelayer_name (输入控制) string → HTuplestrHTupleHtuple (string) (string) (HString) (char*)
输出层的名称。
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", 'output_mode'"output_mode""output_mode""output_mode""output_mode""output_mode"
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)
泛型输入参数值。
默认值:
[]
建议值:
'default'"default""default""default""default""default", 'no_log_training'"no_log_training""no_log_training""no_log_training""no_log_training""no_log_training", 'log_inference'"log_inference""log_inference""log_inference""log_inference""log_inference", 'true'"true""true""true""true""true", 'false'"false""false""false""false""false"
DLLayerSoftMaxDLLayerSoftMaxDLLayerSoftMaxDLLayerSoftMaxDLLayerSoftMaxdllayer_soft_max (输出控制) dl_layer → HDlLayer, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
软最大化层。
模块
深度学习训练