create_dl_layer_inputT_create_dl_layer_inputCreateDlLayerInputCreateDlLayerInputcreate_dl_layer_input创建深度学习层输入(算子)
名称
create_dl_layer_inputT_create_dl_layer_inputCreateDlLayerInputCreateDlLayerInputcreate_dl_layer_input — 创建输入层。
签名
void CreateDlLayerInput(const HTuple& LayerName, const HTuple& Shape, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* DLLayerInput)
void HDlLayer::HDlLayer(const HString& LayerName, const HTuple& Shape, const HTuple& GenParamName, const HTuple& GenParamValue)
void HDlLayer::HDlLayer(const HString& LayerName, const HTuple& Shape, const HString& GenParamName, const HString& GenParamValue)
void HDlLayer::HDlLayer(const char* LayerName, const HTuple& Shape, const char* GenParamName, const char* GenParamValue)
void HDlLayer::HDlLayer(const wchar_t* LayerName, const HTuple& Shape, const wchar_t* GenParamName, const wchar_t* GenParamValue)
(
Windows only)
void HDlLayer::CreateDlLayerInput(const HString& LayerName, const HTuple& Shape, const HTuple& GenParamName, const HTuple& GenParamValue)
void HDlLayer::CreateDlLayerInput(const HString& LayerName, const HTuple& Shape, const HString& GenParamName, const HString& GenParamValue)
void HDlLayer::CreateDlLayerInput(const char* LayerName, const HTuple& Shape, const char* GenParamName, const char* GenParamValue)
void HDlLayer::CreateDlLayerInput(const wchar_t* LayerName, const HTuple& Shape, const wchar_t* GenParamName, const wchar_t* GenParamValue)
(
Windows only)
static void HOperatorSet.CreateDlLayerInput(HTuple layerName, HTuple shape, HTuple genParamName, HTuple genParamValue, out HTuple DLLayerInput)
public HDlLayer(string layerName, HTuple shape, HTuple genParamName, HTuple genParamValue)
public HDlLayer(string layerName, HTuple shape, string genParamName, string genParamValue)
void HDlLayer.CreateDlLayerInput(string layerName, HTuple shape, HTuple genParamName, HTuple genParamValue)
void HDlLayer.CreateDlLayerInput(string layerName, HTuple shape, string genParamName, string genParamValue)
描述
算子 create_dl_layer_inputcreate_dl_layer_inputCreateDlLayerInputCreateDlLayerInputCreateDlLayerInputcreate_dl_layer_input 创建一个输入层,其空间维度由 ShapeShapeShapeShapeshapeshape 指定,该输入层的句柄通过
DLLayerInputDLLayerInputDLLayerInputDLLayerInputDLLayerInputdllayer_input 返回。
参数 LayerNameLayerNameLayerNameLayerNamelayerNamelayer_name 用于设置单个层的名称。请注意,若使用 create_dl_modelcreate_dl_modelCreateDlModelCreateDlModelCreateDlModelcreate_dl_model 创建模型,则创建网络中的每个层必须具有唯一名称。
当创建的模型通过 apply_dl_modelapply_dl_modelApplyDlModelApplyDlModelApplyDlModelapply_dl_model 或 train_dl_model_batchtrain_dl_model_batchTrainDlModelBatchTrainDlModelBatchTrainDlModelBatchtrain_dl_model_batch 等方法应用时,必须能够将输入映射到其对应的输入层。应用模型的算子需要一个输入字典 DLSample(详见 深度学习 / 模型)。上述映射通过字典条目实现,其中键值对应输入层名称。因此,该层的输入样本字典需包含键值为 LayerNameLayerNameLayerNameLayerNamelayerNamelayer_name 的条目(除非
'input_type'"input_type""input_type""input_type""input_type""input_type" 设置为 'constant'"constant""constant""constant""constant""constant",详见下文)。
参数 ShapeShapeShapeShapeshapeshape 定义输入值的形状(即输入字典 DLSample 中的值),必须为长度为三的元组,包含输入的 width、height 和 depth。元组值需为整数,且根据输入类型具有不同含义:
批次大小需在通过
create_dl_modelcreate_dl_modelCreateDlModelCreateDlModelCreateDlModelcreate_dl_model 创建模型后,使用
set_dl_model_paramset_dl_model_paramSetDlModelParamSetDlModelParamSetDlModelParamset_dl_model_param 进行设置。
支持以下泛型参数 GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name 及其对应值 GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value:
- 'allow_smaller_tuple'"allow_smaller_tuple""allow_smaller_tuple""allow_smaller_tuple""allow_smaller_tuple""allow_smaller_tuple":
-
对于元组输入,将
'allow_smaller_tuple'"allow_smaller_tuple""allow_smaller_tuple""allow_smaller_tuple""allow_smaller_tuple""allow_smaller_tuple" 设为 'true'"true""true""true""true""true" 允许输入元组的值个数少于
ShapeShapeShapeShapeshapeshape 指定的总维度。例如当输入对应单张图像中的对象数量且各图像对象数量不同时即属此类情况。若实际值个数少于 ShapeShapeShapeShapeshapeshape 总维度规定的最大值,则剩余值将被设为 0。
ShapeShapeShapeShapeshapeshape 参数应设置为能容纳预期最大长度。以上述示例而言,即整个数据集中单张图像内对象的最大数量。
默认值: 'false'"false""false""false""false""false"。
- 'const_val'"const_val""const_val""const_val""const_val""const_val":
-
常量输出值。
限制:
仅可设置整数或浮点数。当 'input_type'"input_type""input_type""input_type""input_type""input_type" 设为 'constant'"constant""constant""constant""constant""constant" 时,此值才可设置或获取。
默认值: 0.0。
- 'input_type'"input_type""input_type""input_type""input_type""input_type":
-
定义预期输入的类型。可取值如下:
- 'default'"default""default""default""default""default":
该层预期接收与批次大小对应数量的输入图像。
- 'region_to_bin'"region_to_bin""region_to_bin""region_to_bin""region_to_bin""region_to_bin":
该层期望接收区域元组作为输入,并在内部将其转换为二值图像,其中每个区域编码于一个深度通道中。超出指定尺寸的区域将被裁剪至 ShapeShapeShapeShapeshapeshape 定义的宽度和高度。区域的最大数量由 ShapeShapeShapeShapeshapeshape 的深度决定。若给定区域数少于最大值,输出将用空值( 0 )图像填充。例如当区域对应图像内对象且对象数量随图像变化时即会出现此情况。
- 'constant'"constant""constant""constant""constant""constant":
该层不期望输入字典包含任何键值对。相反,该层输出中的所有条目均填充为 'const_val'"const_val""const_val""const_val""const_val""const_val" 指定的值。
默认值: '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_inputcreate_dl_layer_inputCreateDlLayerInputCreateDlLayerInputCreateDlLayerInputcreate_dl_layer_input
算子创建的层,其特定参数可通过其他算子进行设置与检索。下表概述了可通过 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 创建的模型。
|
泛型层参数 |
设置 |
获取 |
|
'allow_smaller_tuple'"allow_smaller_tuple""allow_smaller_tuple""allow_smaller_tuple""allow_smaller_tuple""allow_smaller_tuple" |
|
|
|
'const_val'"const_val""const_val""const_val""const_val""const_val" |
|
|
|
'input_type'"input_type""input_type""input_type""input_type""input_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" |
|
|
执行信息
- 多线程类型:可重入(与非独占算子并行运行)。
- 多线程作用域:全局(可从任何线程调用)。
- 未采用并行化处理。
此算子返回一个句柄。请注意,即使该句柄被用作特定算子的输入参数,这些算子仍可能改变此句柄类型的实例状态。
参数
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*)
泛型输入参数名称。
默认值:
[]
值列表:
'allow_smaller_tuple'"allow_smaller_tuple""allow_smaller_tuple""allow_smaller_tuple""allow_smaller_tuple""allow_smaller_tuple", 'const_val'"const_val""const_val""const_val""const_val""const_val", 'input_type'"input_type""input_type""input_type""input_type""input_type", '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)
泛型输入参数值。
默认值:
[]
建议值:
0.0, 'constant'"constant""constant""constant""constant""constant", 'default'"default""default""default""default""default", 'false'"false""false""false""false""false", 'region_to_bin'"region_to_bin""region_to_bin""region_to_bin""region_to_bin""region_to_bin", 'true'"true""true""true""true""true"
DLLayerInputDLLayerInputDLLayerInputDLLayerInputDLLayerInputdllayer_input (输出控制) dl_layer → HDlLayer, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
输入层。
示例(HDevelop)
* Create a model for summation.
create_dl_layer_input ('input_a', [2, 3, 4], [], [], DLLayerInputA)
create_dl_layer_input ('input_b', [2, 3, 4], [], [], DLLayerInputB)
create_dl_layer_elementwise ([DLLayerInputA, DLLayerInputB], 'sum', \
'sum', [], [], [], DLLayerElementWise)
create_dl_model (DLLayerElementWise, DLModel)
set_dl_model_param (DLModel, 'runtime', 'cpu')
*
* Add 'input_a' as an inference model output.
set_dl_model_layer_param (DLModel, 'input_a', 'is_inference_output', 'true')
*
* Feed input data as tuple (a) or image (b).
create_dict (Sample)
set_dict_tuple (Sample, 'input_a', [1:(2*3*4)])
gen_empty_obj (InputB)
for I := 1 to 4 by 1
gen_image_const (Channel, 'real', 2, 3)
get_region_points (Channel, Rows, Cols)
set_grayval (Channel, Rows, Cols, gen_tuple_const(|Rows|, I))
append_channel (InputB, Channel, InputB)
endfor
set_dict_object (InputB, Sample, 'input_b')
*
* Apply the model for summation and get results.
set_dl_model_param (DLModel, 'batch_size', 2)
apply_dl_model (DLModel, [Sample,Sample], [], Result)
get_dict_object (Sum, Result[0], 'sum')
get_dict_object (TupleInputA, Result[1], 'input_a')
可能的后继
create_dl_layer_activationcreate_dl_layer_activationCreateDlLayerActivationCreateDlLayerActivationCreateDlLayerActivationcreate_dl_layer_activation,
create_dl_layer_batch_normalizationcreate_dl_layer_batch_normalizationCreateDlLayerBatchNormalizationCreateDlLayerBatchNormalizationCreateDlLayerBatchNormalizationcreate_dl_layer_batch_normalization,
create_dl_layer_class_id_conversioncreate_dl_layer_class_id_conversionCreateDlLayerClassIdConversionCreateDlLayerClassIdConversionCreateDlLayerClassIdConversioncreate_dl_layer_class_id_conversion,
create_dl_layer_class_id_conversioncreate_dl_layer_class_id_conversionCreateDlLayerClassIdConversionCreateDlLayerClassIdConversionCreateDlLayerClassIdConversioncreate_dl_layer_class_id_conversion,
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,
create_dl_layer_depth_maxcreate_dl_layer_depth_maxCreateDlLayerDepthMaxCreateDlLayerDepthMaxCreateDlLayerDepthMaxcreate_dl_layer_depth_max,
create_dl_layer_dropoutcreate_dl_layer_dropoutCreateDlLayerDropoutCreateDlLayerDropoutCreateDlLayerDropoutcreate_dl_layer_dropout,
create_dl_layer_elementwisecreate_dl_layer_elementwiseCreateDlLayerElementwiseCreateDlLayerElementwiseCreateDlLayerElementwisecreate_dl_layer_elementwise,
create_dl_layer_loss_cross_entropycreate_dl_layer_loss_cross_entropyCreateDlLayerLossCrossEntropyCreateDlLayerLossCrossEntropyCreateDlLayerLossCrossEntropycreate_dl_layer_loss_cross_entropy,
create_dl_layer_loss_ctccreate_dl_layer_loss_ctcCreateDlLayerLossCtcCreateDlLayerLossCtcCreateDlLayerLossCtccreate_dl_layer_loss_ctc,
create_dl_layer_loss_distancecreate_dl_layer_loss_distanceCreateDlLayerLossDistanceCreateDlLayerLossDistanceCreateDlLayerLossDistancecreate_dl_layer_loss_distance,
create_dl_layer_loss_focalcreate_dl_layer_loss_focalCreateDlLayerLossFocalCreateDlLayerLossFocalCreateDlLayerLossFocalcreate_dl_layer_loss_focal,
create_dl_layer_loss_hubercreate_dl_layer_loss_huberCreateDlLayerLossHuberCreateDlLayerLossHuberCreateDlLayerLossHubercreate_dl_layer_loss_huber,
create_dl_layer_lrncreate_dl_layer_lrnCreateDlLayerLrnCreateDlLayerLrnCreateDlLayerLrncreate_dl_layer_lrn,
create_dl_layer_poolingcreate_dl_layer_poolingCreateDlLayerPoolingCreateDlLayerPoolingCreateDlLayerPoolingcreate_dl_layer_pooling,
create_dl_layer_reshapecreate_dl_layer_reshapeCreateDlLayerReshapeCreateDlLayerReshapeCreateDlLayerReshapecreate_dl_layer_reshape,
create_dl_layer_softmaxcreate_dl_layer_softmaxCreateDlLayerSoftmaxCreateDlLayerSoftmaxCreateDlLayerSoftmaxcreate_dl_layer_softmax,
create_dl_layer_transposed_convolutioncreate_dl_layer_transposed_convolutionCreateDlLayerTransposedConvolutionCreateDlLayerTransposedConvolutionCreateDlLayerTransposedConvolutioncreate_dl_layer_transposed_convolution,
create_dl_layer_zoom_factorcreate_dl_layer_zoom_factorCreateDlLayerZoomFactorCreateDlLayerZoomFactorCreateDlLayerZoomFactorcreate_dl_layer_zoom_factor,
create_dl_layer_zoom_sizecreate_dl_layer_zoom_sizeCreateDlLayerZoomSizeCreateDlLayerZoomSizeCreateDlLayerZoomSizecreate_dl_layer_zoom_size,
create_dl_layer_zoom_to_layer_sizecreate_dl_layer_zoom_to_layer_sizeCreateDlLayerZoomToLayerSizeCreateDlLayerZoomToLayerSizeCreateDlLayerZoomToLayerSizecreate_dl_layer_zoom_to_layer_size
模块
深度学习训练