create_dl_layer_reshapeT_create_dl_layer_reshapeCreateDlLayerReshapeCreateDlLayerReshapecreate_dl_layer_reshape创建深度学习层重塑(算子)

名称

create_dl_layer_reshapeT_create_dl_layer_reshapeCreateDlLayerReshapeCreateDlLayerReshapecreate_dl_layer_reshape — 创建重塑层。

签名

create_dl_layer_reshape( : : DLLayerInput, LayerName, Shape, GenParamName, GenParamValue : DLLayerReshape)

Herror T_create_dl_layer_reshape(const Htuple DLLayerInput, const Htuple LayerName, const Htuple Shape, const Htuple GenParamName, const Htuple GenParamValue, Htuple* DLLayerReshape)

void CreateDlLayerReshape(const HTuple& DLLayerInput, const HTuple& LayerName, const HTuple& Shape, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* DLLayerReshape)

HDlLayer HDlLayer::CreateDlLayerReshape(const HString& LayerName, const HTuple& Shape, const HTuple& GenParamName, const HTuple& GenParamValue) const

HDlLayer HDlLayer::CreateDlLayerReshape(const HString& LayerName, const HTuple& Shape, const HString& GenParamName, const HString& GenParamValue) const

HDlLayer HDlLayer::CreateDlLayerReshape(const char* LayerName, const HTuple& Shape, const char* GenParamName, const char* GenParamValue) const

HDlLayer HDlLayer::CreateDlLayerReshape(const wchar_t* LayerName, const HTuple& Shape, const wchar_t* GenParamName, const wchar_t* GenParamValue) const   ( Windows only)

static void HOperatorSet.CreateDlLayerReshape(HTuple DLLayerInput, HTuple layerName, HTuple shape, HTuple genParamName, HTuple genParamValue, out HTuple DLLayerReshape)

HDlLayer HDlLayer.CreateDlLayerReshape(string layerName, HTuple shape, HTuple genParamName, HTuple genParamValue)

HDlLayer HDlLayer.CreateDlLayerReshape(string layerName, HTuple shape, string genParamName, string genParamValue)

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

描述

算子 create_dl_layer_reshapecreate_dl_layer_reshapeCreateDlLayerReshapeCreateDlLayerReshapeCreateDlLayerReshapecreate_dl_layer_reshape 创建一个重塑层,其句柄在 DLLayerReshapeDLLayerReshapeDLLayerReshapeDLLayerReshapeDLLayerReshapedllayer_reshape 中返回。

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

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

参数 ShapeShapeShapeShapeshapeshape 决定了输出形状,输入数据将转换为此形状。

ShapeShapeShapeShapeshapeshape 参数的值必须采用 [width, height, depth, batch_size] 的形式给出,其中第四个批次大小参数为可选项(详见下文)。数据的整体尺寸必须保持恒定,即:width_out * height_out * depth_out * batch_size_out = width_in * height_in * depth_in * batch_size_in

设置 ShapeShapeShapeShapeshapeshape 值时可选以下方式:

对于使用 create_dl_modelcreate_dl_modelCreateDlModelCreateDlModelCreateDlModelcreate_dl_model 创建的模型,其批次大小应始终可通过 set_dl_model_paramset_dl_model_paramSetDlModelParamSetDlModelParamSetDlModelParamset_dl_model_param 设置。因此,重塑层的输出批次大小要么等于模型批次大小(ShapeShapeShapeShapeshapeshape 中的批次大小设为 0),要么至少有一个重塑维度应自动计算(ShapeShapeShapeShapeshapeshape 中的一个值设为 -1)。

若显式指定批次大小且未设为 0,则 ShapeShapeShapeShapeshapeshape 参数中至少一个维度必须设为 -1。这是必要的,因为使用 create_dl_modelcreate_dl_modelCreateDlModelCreateDlModelCreateDlModelcreate_dl_model 创建的模型,其批次大小应始终可通过 set_dl_model_paramset_dl_model_paramSetDlModelParamSetDlModelParamSetDlModelParamset_dl_model_param 设置。因此,重塑层的输出批次大小要么等于模型的批次大小(ShapeShapeShapeShapeshapeshape 中的批次大小设为 0),要么至少有一个重塑维度应自动计算(ShapeShapeShapeShapeshapeshape 中的一个值设为 -1)。若未指定批次大小,则默认设为 0,此时输出批次大小将等于输入批次大小。

支持以下泛型参数 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_reshapecreate_dl_layer_reshapeCreateDlLayerReshapeCreateDlLayerReshapeCreateDlLayerReshapecreate_dl_layer_reshape 算子创建的层,其特定参数可通过其他算子进行设置与检索。下表概述了可通过 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)
'name'"name""name""name""name""name" (LayerNameLayerNameLayerNameLayerNamelayerNamelayer_name)
'output_depth'"output_depth""output_depth""output_depth""output_depth""output_depth" (ShapeShapeShapeShapeshapeshape)
'output_height'"output_height""output_height""output_height""output_height""output_height" (ShapeShapeShapeShapeshapeshape)
'output_layer'"output_layer""output_layer""output_layer""output_layer""output_layer" (ShapeShapeShapeShapeshapeshape)
'output_width'"output_width""output_width""output_width""output_width""output_width" (ShapeShapeShapeShapeshapeshape)
'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*)

输出层的名称。

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

输出层数据的形状。

默认值: [224,224,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"

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

重塑层。

示例(HDevelop)

* Minimal example for reshape-layer.
create_dl_layer_input ('input', [64, 32, 10], [], [], DLLayerInput)
create_dl_layer_reshape (DLLayerInput, 'reshape_wh', [32, 64, 0], [], [], \
                         DLLayerReshapeWH)
create_dl_layer_reshape (DLLayerInput, 'reshape_bs', [64, 32, 1, -1], [], \
                         [], DLLayerReshapeBS)
* DLLayerReshapeBS has batch size 10 and depth 1.
get_dl_layer_param (DLLayerReshapeBS, 'shape', ShapeReshapeBS)
* Create a model and change the batch-size.
create_dl_model (DLLayerReshapeBS, DLModel)
set_dl_model_param (DLModel, 'batch_size', 2)
* DLLayerReshapeBS has batch size 20 now.
get_dl_model_layer_param (DLModel, 'reshape_bs', 'shape', ShapeReshapeBS)

可能的前趋

create_dl_layer_inputcreate_dl_layer_inputCreateDlLayerInputCreateDlLayerInputCreateDlLayerInputcreate_dl_layer_input, create_dl_layer_concatcreate_dl_layer_concatCreateDlLayerConcatCreateDlLayerConcatCreateDlLayerConcatcreate_dl_layer_concat

可能的后继

create_dl_layer_convolutioncreate_dl_layer_convolutionCreateDlLayerConvolutionCreateDlLayerConvolutionCreateDlLayerConvolutioncreate_dl_layer_convolution, create_dl_layer_densecreate_dl_layer_denseCreateDlLayerDenseCreateDlLayerDenseCreateDlLayerDensecreate_dl_layer_dense

模块

深度学习训练