Skip to content

create_dl_layer_convolutionCreateDlLayerConvolutionCreateDlLayerConvolutioncreate_dl_layer_convolutionT_create_dl_layer_convolution🔗

説明🔗

create_dl_layer_convolutionCreateDlLayerConvolutionCreateDlLayerConvolutioncreate_dl_layer_convolutionT_create_dl_layer_convolution — 畳み込み層を作成する。

書式🔗

create_dl_layer_convolution( dl_layer DLLayerInput, string LayerName, number KernelSize, number Dilation, number Stride, number NumKernel, number Groups, number Padding, number Activation, attribute.name GenParamName, attribute.value GenParamValue, out dl_layer DLLayerConvolution )void CreateDlLayerConvolution( const HTuple& DLLayerInput, const HTuple& LayerName, const HTuple& KernelSize, const HTuple& Dilation, const HTuple& Stride, const HTuple& NumKernel, const HTuple& Groups, const HTuple& Padding, const HTuple& Activation, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* DLLayerConvolution )static void HOperatorSet.CreateDlLayerConvolution( HTuple DLLayerInput, HTuple layerName, HTuple kernelSize, HTuple dilation, HTuple stride, HTuple numKernel, HTuple groups, HTuple padding, HTuple activation, HTuple genParamName, HTuple genParamValue, out HTuple DLLayerConvolution )def create_dl_layer_convolution( dllayer_input: HHandle, layer_name: str, kernel_size: MaybeSequence[int], dilation: MaybeSequence[int], stride: MaybeSequence[int], num_kernel: int, groups: int, padding: MaybeSequence[Union[str, int]], activation: str, gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[Union[int, float, str]] ) -> HHandle

Herror T_create_dl_layer_convolution( const Htuple DLLayerInput, const Htuple LayerName, const Htuple KernelSize, const Htuple Dilation, const Htuple Stride, const Htuple NumKernel, const Htuple Groups, const Htuple Padding, const Htuple Activation, const Htuple GenParamName, const Htuple GenParamValue, Htuple* DLLayerConvolution )

HDlLayer HDlLayer::CreateDlLayerConvolution( const HString& LayerName, const HTuple& KernelSize, const HTuple& Dilation, const HTuple& Stride, Hlong NumKernel, Hlong Groups, const HTuple& Padding, const HString& Activation, const HTuple& GenParamName, const HTuple& GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerConvolution( const HString& LayerName, Hlong KernelSize, Hlong Dilation, Hlong Stride, Hlong NumKernel, Hlong Groups, const HString& Padding, const HString& Activation, const HString& GenParamName, const HString& GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerConvolution( const char* LayerName, Hlong KernelSize, Hlong Dilation, Hlong Stride, Hlong NumKernel, Hlong Groups, const char* Padding, const char* Activation, const char* GenParamName, const char* GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerConvolution( const wchar_t* LayerName, Hlong KernelSize, Hlong Dilation, Hlong Stride, Hlong NumKernel, Hlong Groups, const wchar_t* Padding, const wchar_t* Activation, const wchar_t* GenParamName, const wchar_t* GenParamValue ) const (Windows only)

HDlLayer HDlLayer.CreateDlLayerConvolution( string layerName, HTuple kernelSize, HTuple dilation, HTuple stride, int numKernel, int groups, HTuple padding, string activation, HTuple genParamName, HTuple genParamValue )

HDlLayer HDlLayer.CreateDlLayerConvolution( string layerName, int kernelSize, int dilation, int stride, int numKernel, int groups, string padding, string activation, string genParamName, string genParamValue )

説明🔗

オペレータ create_dl_layer_convolutionCreateDlLayerConvolution は Groupsgroupsgroups の フィルタグループに NumKernelnumKernelnum_kernel のカーネルを持つ畳み込み層 を生成し、そのハンドルを DLLayerConvolutionDLLayerConvolutiondllayer_convolution に返します。

パラメーター DLLayerInputDLLayerInputdllayer_input は、値として層のハンドルを受け取り、入力される層を決定します。

パラメーター LayerNamelayerNamelayer_name は、個々の層の名前を設定します。 create_dl_modelCreateDlModel によってモデルを生成する場合、 生成されるネットワークの各層には固有の名前が必要です。

KernelSizekernelSizekernel_size はカーネルのwidthおよびheightを決定します。

Dilationdilationdilation にはフィルタのwidthおよびheightの膨張係数を決定します。

Stridestridestride はフィルタが移動する量を決定します。

KernelSizekernelSizekernel_size、Dilationdilationdilation および Stridestridestride は、 以下の値を設定できます。

  • 単一の値では幅および高さに同一の値

  • tupleとしてそれぞれ [width, height] や [column, row]

パラメーターGroupsgroupsgroupsはフィルターグループの数を設定します。

パラメーターNumKernelnumKernelnum_kernelはフィルターカーネルの数を設定します。 NumKernelnumKernelnum_kernelはGroupsgroupsgroupsの倍数である必要があります。

パラメーター Paddingpaddingpadding では、入力画像の画像境界上に、 輝度値が0のピクセルをいくつ付加するかを決定するパディングを設定します。 サポートされている値は下記の通りです。

  • 'half_kernel_size'"half_kernel_size": 付加されるピクセルの数は、KernelSizekernelSizekernel_sizeの設定に依存します。 より正確に言うと、\(\lfloor\textrm{KernelSize} /2 \rfloor\) で与えられます。 ここで、左と右の境界のパディングは、KernelSizekernelSizekernel_sizeのwidthの値が、上と下の境界のパディングは KernelSizekernelSizekernel_sizeのheightの値がそれぞれ参照されます。

  • 'none'"none": ピクセルは付加されません。

  • ピクセル数: 各境界に付加するピクセル数を設定します。 以下の長さのtupleがサポートされています。:

    • 数字1つ: 四方向(左右上下)に指定した数だけパディングを行います。

    • 数字2つ: 左右方向と上下方向でパディングを行います。: [l/r, t/b]。

    • 数字4つ: 左・右・上・下の順に指定した数だけパディングを行います。: [l,r,t,b]。

      制限: 'runtime'"runtime" 'gpu'"gpu"は、非対称のパディングをサポートしていません。 つまり、左右のパディング値はもちろん、上下のパディング値も同じである必要があります。

    制限: 整数のパディング値は、対応する寸法のKernelSizekernelSizekernel_sizeのセットよりも小さくなければなりません。

畳み込み層の出力寸法は以下の式で与えられます。

\[\begin{eqnarray*} output\_dim &=& \left\lfloor\frac{input\_dim + 2 (padding\_begin + padding\_end)} {stride}\right.\\ & & - \left.\frac{Kernel\_Size + (Kernel\_Size - 1) (Dilation - 1)} {Stride}\right\rfloor + 1 \end{eqnarray*}\]

ここで、以下の値が使用されます: \(output\_dim\): 出力の幅/高さ, \(input\_dim\): 入力の幅/高さ, \(padding\_begin\): 入力画像の左と上に付加するピクセル数, \(padding\_end\): 入力画像の右と下に付加するピクセル数。

パラメーターActivationactivationactivationは、ランタイムパフォーマンスを最適化するために、畳み込み後に 活性化関数を実行するかどうかを決定します。

  • 'relu'"relu": 畳み込み後に活性化関数としてReLUを用いることができます。

  • 'sigmoid'"sigmoid": 畳み込み後に活性化関数としてシグモイド関数を用いることができます。

  • 'tanh'"tanh": 畳み込み後に活性化関数としてTanhを用いることができます。

    ReLUの上限を汎用パラメーター'upper_bound'"upper_bound"を使用して設定することができます。 (create_dl_layer_activationCreateDlLayerActivationを参照) Note: Leaky ReLUを指定することはできません。

  • 'none'"none": 活性化関数を用いません。

畳み込み層に関するより一般的な情報については “Solution Guide on Classification” を、 層の算術に関するより詳細な情報については下に示すリファレンスを参照ください。

下記の GenParamNamegenParamNamegen_param_name および GenParamValuegenParamValuegen_param_value が使用できます:

  • 'bias_filler'"bias_filler": 値の説明については 'weight_filler'"weight_filler" を参照してください。

    値のリスト: 'xavier'"xavier", 'msra'"msra", 'const'"const".

    初期値: 'const'"const"

  • 'bias_filler_variance_norm'"bias_filler_variance_norm": 値の説明については 'weight_filler_variance_norm'"weight_filler_variance_norm" を 参照してください。

    値のリスト: 'norm_in'"norm_in", 'norm_out'"norm_out", 'norm_average'"norm_average".

    初期値: 'norm_in'"norm_in"

  • 'bias_filler_const_val'"bias_filler_const_val": 'bias_filler'"bias_filler" が 'const'"const"に設定されている場合の定数バイアス項の初期化値を指定します。

    制限: 'bias_filler'"bias_filler" がその他の値では無視されます。

    初期値: 00

  • 'bias_term'"bias_term": 作成された畳み込み層がバイアス項を 持っているか ('true'"true") 持っていないか ('false'"false") を 決定します。

    初期値: 'true'"true"

  • 'is_inference_output'"is_inference_output": apply_dl_modelApplyDlModel が Outputsoutputsoutputs としてこの層を指定していなくても、 ディクショナリ DLResultBatchDLResultBatchdlresult_batch にこの層の出力を含めるか ('true'"true")、 含めないか ('false'"false") を設定します。

    初期値: 'false'"false"

  • 'learning_rate_multiplier'"learning_rate_multiplier": 学習時に使用される、この層の 学習率の乗数です。 'learning_rate_multiplier'"learning_rate_multiplier" が0.00.0のとき、その層は学習時に おいてスキップされます。

    初期値: 1.01.0

  • 'learning_rate_multiplier_bias'"learning_rate_multiplier_bias": バイアス項の学習率を表す 乗数です。トータルのバイアス学習率は 'learning_rate_multiplier_bias'"learning_rate_multiplier_bias" と 'learning_rate_multiplier'"learning_rate_multiplier" の積となります。

    初期値: 1.01.0

  • 'upper_bound'"upper_bound": ReLUの上限値を定義するFloat値です。 上限値の設定を解除するには、'upper_bound'"upper_bound"に空のtuple を設定します。

    初期値: [][]

  • 'weight_filler'"weight_filler": このパラメータは、重みの初期化モードを定義します。 下記の値が使用可能です。:

    • 'const'"const": 重みは固定値で初期化されます。

    • 'msra'"msra": ガウス分布に基づき重みが設定されます。

    • 'xavier'"xavier": 重みは一様分布に基づき設定されます。

    初期値: 'xavier'"xavier"

  • 'weight_filler_const_val'"weight_filler_const_val": 定数重み初期化値を指定します。

    制限: 'weight_filler'"weight_filler" が'const'"const"に設定されている場合のみに有効。 'weight_filler'"weight_filler"が他の値では無視されます。

    初期値: 0.50.5

  • 'weight_filler_variance_norm'"weight_filler_variance_norm": このパラメータは 'weight_filler'"weight_filler" の値の範囲を決定します。以下の値が 使用可能です。:

    • 'norm_average'"norm_average": 値は、入力と出力のサイズの平均値に 基づいて設定されます

    • 'norm_in'"norm_in": 値は、入力サイズに基づいて設定されます

    • 'norm_out'"norm_out": 値は、出力サイズに基づいて設定されます

    初期値: 'norm_in'"norm_in"

create_dl_layer_convolutionCreateDlLayerConvolution を使用して作成された層の 一部のパラメータは他のオペレータを使用して設定・取得することができます。 次の表に、set_dl_model_layer_paramSetDlModelLayerParam を使用して設定、および get_dl_model_layer_paramGetDlModelLayerParam または get_dl_layer_paramGetDlLayerParam を使用して取得できるパラメータの概要を示します。 set_dl_model_layer_paramSetDlModelLayerParam および get_dl_model_layer_paramGetDlModelLayerParam は create_dl_modelCreateDlModel によって作成されたモデルを必要とします。

層パラメーター set get
'activation_mode'"activation_mode" (Activationactivationactivation) x
'dilation'"dilation" (Dilationdilationdilation) x
'groups'"groups" (Groupsgroupsgroups) x
'input_depth'"input_depth" x
'input_layer'"input_layer" (DLLayerInputDLLayerInputdllayer_input) x
'kernel_size'"kernel_size" (KernelSizekernelSizekernel_size) x
'name'"name" (LayerNamelayerNamelayer_name) x x
'num_kernels'"num_kernels" (NumKernelnumKernelnum_kernel) x
'output_layer'"output_layer" (DLLayerConvolutionDLLayerConvolutiondllayer_convolution) x
'padding'"padding" (Paddingpaddingpadding) x
'padding_type'"padding_type" (Paddingpaddingpadding) x
'shape'"shape" x
'stride'"stride" (Stridestridestride) x
'type'"type" x
汎用層パラメーター set get
'bias_filler'"bias_filler" x x
'bias_filler_const_val'"bias_filler_const_val" x x
'bias_filler_variance_norm'"bias_filler_variance_norm" x x
'bias_term'"bias_term" x
'is_inference_output'"is_inference_output" x x
'learning_rate_multiplier'"learning_rate_multiplier" x x
'learning_rate_multiplier_bias'"learning_rate_multiplier_bias" x x
'num_trainable_params'"num_trainable_params" x
'upper_bound'"upper_bound" x x
'weight_filler'"weight_filler" x x
'weight_filler_const_val'"weight_filler_const_val" x x
'weight_filler_variance_norm'"weight_filler_variance_norm" x x

実行情報🔗

実行情報
  • マルチスレッドタイプ: リエントラント(非排他なオペレーターと並列に動作)

  • マルチスレッドスコープ: グローバル(他のスレッドから呼び出される可能性あり)

  • 並列演算処理には未対応

パラメーター🔗

DLLayerInputDLLayerInputdllayer_input (input_control) dl_layer → (handle)HTuple (HHandle)HDlLayer, HTuple (IntPtr)HHandleHtuple (handle)

作成する畳み込み層への入力となる層のハンドル

LayerNamelayerNamelayer_name (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

出力層の名前

KernelSizekernelSizekernel_size (input_control) number(-array) → (integer)HTuple (Hlong)HTuple (int / long)MaybeSequence[int]Htuple (Hlong)

フィルタカーネルの幅および高さ

初期値: 33

Dilationdilationdilation (input_control) number(-array) → (integer)HTuple (Hlong)HTuple (int / long)MaybeSequence[int]Htuple (Hlong)

幅および高さ方向のフィルタの膨張量.

初期値: 11

Stridestridestride (input_control) number(-array) → (integer)HTuple (Hlong)HTuple (int / long)MaybeSequence[int]Htuple (Hlong)

幅および高さ方向のフィルタの移動量

初期値: 11

NumKernelnumKernelnum_kernel (input_control) number → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

フィルタカーネルの数

初期値: 6464

Groupsgroupsgroups (input_control) number → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

フィルタグループの数.

初期値: 11

Paddingpaddingpadding (input_control) number(-array) → (string / integer)HTuple (HString / Hlong)HTuple (string / int / long)MaybeSequence[Union[str, int]]Htuple (char* / Hlong)

パディングサイズに対応するパディング形式

初期値: 'none'"none"
値のリスト: [all], [width, height], [left, right, top, bottom], 'half_kernel_size', 'none'[all], [width, height], [left, right, top, bottom], "half_kernel_size", "none"
推奨値: 'none', 'half_kernel_size'"none", "half_kernel_size"

Activationactivationactivation (input_control) number → (string)HTuple (HString)HTuple (string)strHtuple (char*)

ReLU、シグモイド、Tanhの活性化 (オプション)

初期値: 'none'"none"
値のリスト: 'none', 'relu', 'sigmoid', 'tanh'"none", "relu", "sigmoid", "tanh"

GenParamNamegenParamNamegen_param_name (input_control) attribute.name(-array) → (string)HTuple (HString)HTuple (string)MaybeSequence[str]Htuple (char*)

一般パラメータの名前

初期値: [][]
値のリスト: 'bias_filler', 'bias_filler_const_val', 'bias_filler_variance_norm', 'bias_term', 'is_inference_output', 'learning_rate_multiplier', 'learning_rate_multiplier_bias', 'upper_bound', 'weight_filler', 'weight_filler_const_val', 'weight_filler_variance_norm'"bias_filler", "bias_filler_const_val", "bias_filler_variance_norm", "bias_term", "is_inference_output", "learning_rate_multiplier", "learning_rate_multiplier_bias", "upper_bound", "weight_filler", "weight_filler_const_val", "weight_filler_variance_norm"

GenParamValuegenParamValuegen_param_value (input_control) attribute.value(-array) → (string / integer / real)HTuple (HString / Hlong / double)HTuple (string / int / long / double)MaybeSequence[Union[int, float, str]]Htuple (char* / Hlong / double)

一般パラメータの値

初期値: [][]
推奨値: 'xavier', 'msra', 'const', 'nearest_neighbor', 'bilinear', 'norm_in', 'norm_out', 'norm_average', 'true', 'false', 1.0, 0.9, 0.0"xavier", "msra", "const", "nearest_neighbor", "bilinear", "norm_in", "norm_out", "norm_average", "true", "false", 1.0, 0.9, 0.0

DLLayerConvolutionDLLayerConvolutiondllayer_convolution (output_control) dl_layer → (handle)HTuple (HHandle)HDlLayer, HTuple (IntPtr)HHandleHtuple (handle)

作成した畳み込み層のハンドル

参考文献🔗

V. Dumoulin, F. Visin: "A guide to convolution arithmetic for deep learning”, 2018, http://arxiv.org/abs/1603.07285

モジュール🔗

Deep Learning Professional