create_dl_layer_permutationT_create_dl_layer_permutationCreateDlLayerPermutationCreateDlLayerPermutationcreate_dl_layer_permutation创建深度学习层置换(算子)

名称

create_dl_layer_permutationT_create_dl_layer_permutationCreateDlLayerPermutationCreateDlLayerPermutationcreate_dl_layer_permutation — 创建置换层。

签名

create_dl_layer_permutation( : : DLLayerInput, LayerName, Permutation, GenParamName, GenParamValue : DLLayerPermutation)

Herror T_create_dl_layer_permutation(const Htuple DLLayerInput, const Htuple LayerName, const Htuple Permutation, const Htuple GenParamName, const Htuple GenParamValue, Htuple* DLLayerPermutation)

void CreateDlLayerPermutation(const HTuple& DLLayerInput, const HTuple& LayerName, const HTuple& Permutation, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* DLLayerPermutation)

HDlLayer HDlLayer::CreateDlLayerPermutation(const HString& LayerName, const HTuple& Permutation, const HTuple& GenParamName, const HTuple& GenParamValue) const

HDlLayer HDlLayer::CreateDlLayerPermutation(const HString& LayerName, const HTuple& Permutation, const HString& GenParamName, const HString& GenParamValue) const

HDlLayer HDlLayer::CreateDlLayerPermutation(const char* LayerName, const HTuple& Permutation, const char* GenParamName, const char* GenParamValue) const

HDlLayer HDlLayer::CreateDlLayerPermutation(const wchar_t* LayerName, const HTuple& Permutation, const wchar_t* GenParamName, const wchar_t* GenParamValue) const   ( Windows only)

static void HOperatorSet.CreateDlLayerPermutation(HTuple DLLayerInput, HTuple layerName, HTuple permutation, HTuple genParamName, HTuple genParamValue, out HTuple DLLayerPermutation)

HDlLayer HDlLayer.CreateDlLayerPermutation(string layerName, HTuple permutation, HTuple genParamName, HTuple genParamValue)

HDlLayer HDlLayer.CreateDlLayerPermutation(string layerName, HTuple permutation, string genParamName, string genParamValue)

def create_dl_layer_permutation(dllayer_input: HHandle, layer_name: str, permutation: Sequence[int], gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[Union[int, float, str]]) -> HHandle

描述

算子 create_dl_layer_permutationcreate_dl_layer_permutationCreateDlLayerPermutationCreateDlLayerPermutationCreateDlLayerPermutationcreate_dl_layer_permutation 创建一个置换层,其句柄通过 DLLayerPermutationDLLayerPermutationDLLayerPermutationDLLayerPermutationDLLayerPermutationdllayer_permutation 返回。

参数 DLLayerInputDLLayerInputDLLayerInputDLLayerInputDLLayerInputdllayer_input 确定输入层,并期望层句柄作为值。

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

参数 PermutationPermutationPermutationPermutationpermutationpermutation 决定了 DLLayerInputDLLayerInputDLLayerInputDLLayerInputDLLayerInputdllayer_input 轴的新顺序,输入轴应按此顺序重新排列。

PermutationPermutationPermutationPermutationpermutationpermutation 的格式为 [index width, index height, index depth, index batch],其中索引对应输入的维度。例如,[0, 1, 3, 2] 将导致深度轴与批次轴互换。因此每个索引必须唯一且取自集合 '{0, 1, 2, 3}'"{0, 1, 2, 3}""{0, 1, 2, 3}""{0, 1, 2, 3}""{0, 1, 2, 3}""{0, 1, 2, 3}"

使用 CPU 设备时,某些 PermutationPermutationPermutationPermutationpermutationpermutation 值会导致内部代码无法优化,从而增加运行时间。此时,层参数 'fall_back_to_baseline'"fall_back_to_baseline""fall_back_to_baseline""fall_back_to_baseline""fall_back_to_baseline""fall_back_to_baseline" 将被设置为 'true'"true""true""true""true""true"

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

层参数 设置 获取
'fall_back_to_baseline'"fall_back_to_baseline""fall_back_to_baseline""fall_back_to_baseline""fall_back_to_baseline""fall_back_to_baseline"
'input_layer'"input_layer""input_layer""input_layer""input_layer""input_layer" (DLLayerInputDLLayerInputDLLayerInputDLLayerInputDLLayerInputdllayer_input)
'name'"name""name""name""name""name" (LayerNameLayerNameLayerNameLayerNamelayerNamelayer_name)
'permutation'"permutation""permutation""permutation""permutation""permutation" (PermutationPermutationPermutationPermutationpermutationpermutation)
'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)

输入层。

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

输出层的名称。

PermutationPermutationPermutationPermutationpermutationpermutation (输入控制)  number-array HTupleSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)

置换轴的顺序。

默认值: [0,1,2,3]

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"

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

置换层。

示例(HDevelop)

* Swap the batch and depth axes with a permutation layer.
create_dl_layer_input ('input_a', [1, 1, 4], ['input_type', 'const_val'], \
                       ['constant', 1.0], DLLayerInputA)
create_dl_layer_input ('input_b', [1, 1, 4], ['input_type', 'const_val'], \
                       ['constant', 2.0], DLLayerInputB)
create_dl_layer_concat ([DLLayerInputA, DLLayerInputB], 'concat', 'batch', \
                        [], [], DLLayerConcat)
create_dl_layer_permutation (DLLayerConcat, 'permute', [0,1,3,2], \
                             [], [], DLLayerPermute)
create_dl_layer_depth_max (DLLayerPermute, 'depth_max', 'value', \
                           [], [], _, DLLayerDepthMaxValue)
create_dl_model (DLLayerDepthMaxValue, DLModel)
* The expected output values in DLResultBatch.depth_max are [2.0,2.0,2.0,2.0]
query_available_dl_devices (['runtime'], ['cpu'], DLDeviceHandles)
set_dl_model_param (DLModel, 'device', DLDeviceHandles[0])
apply_dl_model (DLModel, dict{}, [], DLResultBatch)

可能的前趋

create_dl_layer_inputcreate_dl_layer_inputCreateDlLayerInputCreateDlLayerInputCreateDlLayerInputcreate_dl_layer_input, create_dl_layer_concatcreate_dl_layer_concatCreateDlLayerConcatCreateDlLayerConcatCreateDlLayerConcatcreate_dl_layer_concat, create_dl_layer_reshapecreate_dl_layer_reshapeCreateDlLayerReshapeCreateDlLayerReshapeCreateDlLayerReshapecreate_dl_layer_reshape

可能的后继

create_dl_layer_convolutioncreate_dl_layer_convolutionCreateDlLayerConvolutionCreateDlLayerConvolutionCreateDlLayerConvolutioncreate_dl_layer_convolution, create_dl_layer_densecreate_dl_layer_denseCreateDlLayerDenseCreateDlLayerDenseCreateDlLayerDensecreate_dl_layer_dense, create_dl_layer_reshapecreate_dl_layer_reshapeCreateDlLayerReshapeCreateDlLayerReshapeCreateDlLayerReshapecreate_dl_layer_reshape

另见

create_dl_layer_reshapecreate_dl_layer_reshapeCreateDlLayerReshapeCreateDlLayerReshapeCreateDlLayerReshapecreate_dl_layer_reshape

模块

深度学习训练