Skip to content

create_dl_layer_sliceCreateDlLayerSliceCreateDlLayerSlicecreate_dl_layer_sliceT_create_dl_layer_slice🔗

説明🔗

create_dl_layer_sliceCreateDlLayerSliceCreateDlLayerSlicecreate_dl_layer_sliceT_create_dl_layer_slice — スライス層を作成します。

書式🔗

create_dl_layer_slice( dl_layer DLLayerInput, string LayerName, number Axes, number StartIndices, number EndIndices, number Steps, attribute.name GenParamName, attribute.value GenParamValue, out dl_layer DLLayerSlice )void CreateDlLayerSlice( const HTuple& DLLayerInput, const HTuple& LayerName, const HTuple& Axes, const HTuple& StartIndices, const HTuple& EndIndices, const HTuple& Steps, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* DLLayerSlice )static void HOperatorSet.CreateDlLayerSlice( HTuple DLLayerInput, HTuple layerName, HTuple axes, HTuple startIndices, HTuple endIndices, HTuple steps, HTuple genParamName, HTuple genParamValue, out HTuple DLLayerSlice )def create_dl_layer_slice( dllayer_input: HHandle, layer_name: str, axes: MaybeSequence[Union[int, str]], start_indices: MaybeSequence[int], end_indices: MaybeSequence[int], steps: MaybeSequence[int], gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[Union[int, float, str]] ) -> HHandle

Herror T_create_dl_layer_slice( const Htuple DLLayerInput, const Htuple LayerName, const Htuple Axes, const Htuple StartIndices, const Htuple EndIndices, const Htuple Steps, const Htuple GenParamName, const Htuple GenParamValue, Htuple* DLLayerSlice )

HDlLayer HDlLayer::CreateDlLayerSlice( const HString& LayerName, const HTuple& Axes, const HTuple& StartIndices, const HTuple& EndIndices, const HTuple& Steps, const HTuple& GenParamName, const HTuple& GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerSlice( const HString& LayerName, Hlong Axes, Hlong StartIndices, Hlong EndIndices, Hlong Steps, const HString& GenParamName, const HString& GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerSlice( const char* LayerName, Hlong Axes, Hlong StartIndices, Hlong EndIndices, Hlong Steps, const char* GenParamName, const char* GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerSlice( const wchar_t* LayerName, Hlong Axes, Hlong StartIndices, Hlong EndIndices, Hlong Steps, const wchar_t* GenParamName, const wchar_t* GenParamValue ) const (Windows only)

HDlLayer HDlLayer.CreateDlLayerSlice( string layerName, HTuple axes, HTuple startIndices, HTuple endIndices, HTuple steps, HTuple genParamName, HTuple genParamValue )

HDlLayer HDlLayer.CreateDlLayerSlice( string layerName, int axes, int startIndices, int endIndices, int steps, string genParamName, string genParamValue )

説明🔗

オペレーター create_dl_layer_sliceCreateDlLayerSlice は、提供された開始および 終了インデックス、ならびにスライス処理のステップサイズに基づき、 指定された軸に沿ってテンソルから単一のスライスを抽出するスライス層を作成します。 スライス層のハンドルは DLLayerSliceDLLayerSlicedllayer_slice に返されます。

パラメータ DLLayerInputDLLayerInputdllayer_input は目的としている層への入力となる層を指定し、 層ハンドルを値として受け取ります。

パラメータ LayerNamelayerNamelayer_name は、個別の層の名前を設定します。 create_dl_modelCreateDlModel を使用してモデルを作成する場合、 作成されたネットワーク内のすべての層には一意の名前が必要であることに注意してください。

以下のパラメータはスライス処理に使用されます:

  • 'starts'"starts" 'axes'"axes" で指定された軸に沿った スライス処理の開始インデックスを決定します。 このパラメータは StartIndicesstartIndicesstart_indices を使用して設定されます。

  • 'ends'"ends" 'axes'"axes" で指定された軸に沿った スライス処理の終了インデックスを決定します。 このパラメータは EndIndicesendIndicesend_indices を使用して設定されます。

  • 'steps'"steps" 'axes'"axes" で指定された軸に沿った スライス処理のステップサイズを決定します。 パラメータ 'steps'"steps" は、空のtupleか、'axes'"axes" と同じ長さである必要があります。 空である場合、すべての 'axes'"axes" に対して 11 がステップとして設定されます。 このパラメータは Stepsstepssteps を使用して設定されます。

  • 'axes'"axes" スライス処理が行われる軸を指定します。 軸はWHC形式(幅、高さ、チャネル)で定義されており、 文字列として指定することもできます。バッチ次元でのスライスはサポートされていません。 このパラメータは Axesaxesaxes を使用して設定されます。

スライス層では、指定された軸に沿ったテンソルのスライスを可能にし、柔軟な調整が可能です。 正しい動作を保証するために、'starts'"starts" および 'ends'"ends" はパラメータ 'axes'"axes" と同じ長さでなければなりません。 'starts'"starts" および 'ends'"ends" の負の値は対応する配列次元のサイズを加算して調整され、 効果的に一回の反復でインデックス作成が可能になります。 その後、負の値はクランプされ、範囲外スライスの防止が図られます。

'axes'"axes" に負の値が指定された場合は、テンソルの総次元数をその軸に加えることで調整されます。 負の値は後ろから数えることを意味します。 許容される範囲は [\(-r\), \(r-1\)] であり、\(r\) = ランク です。 サイズが不明な次元の末尾までスライスするには、前方には H_INT_MAX、後方には H_INT_MIN を 指定することが推奨されます。

軸とインデックスの取り扱い

  • 軸の調整 'axes'"axes" パラメータに指定された負の値は、 入力テンソルのランク \(r\) を各負の軸に加えることで正の値に変換されます:

    \[\begin{eqnarray*} \textrm{axes}[i] \gets \textrm{axes}[i] + r \quad \textrm{if } \textrm{axes}[i] < 0 \end{eqnarray*}\]
  • ‘starts’と’ends’の調整

    • Negative Index Adjustment 'starts'"starts" および 'ends'"ends" に負の値が含まれている場合、 それぞれのテンソル次元サイズを加えることで調整されます:

      'starts'"starts"[\(i\)] はテンソル次元サイズを加えて調整されます。

      \[\begin{eqnarray*} \textrm{starts}[i] \gets \textrm{starts}[i] + \textrm{dims}[\textrm{axes}[i]] \quad \textrm{if } \textrm{starts}[i] < 0 \end{eqnarray*}\]

      'ends'"ends"[\(i\)] はそれぞれのテンソル次元サイズを加えて調整されます。

      \[\begin{eqnarray*} \textrm{ends}[i] \gets \textrm{ends}[i] + \textrm{dims}[\textrm{axes}[i]] \quad \textrm{if } \textrm{ends}[i] < 0 \end{eqnarray*}\]
    • ‘starts’の値のクランプ 調整後の 'starts'"starts" の値は以下の範囲にクランプされます:

      \[\begin{eqnarray*} \textrm{starts}[i] \in [0, \textrm{dims}[\textrm{axes}[i]]] \end{eqnarray*}\]
    • ‘ends’の値のクランプ 調整後の 'ends'"ends" の値はステップ方向に応じてクランプされます:

      • 正方向ステップの場合: 'ends'"ends" は [0, dims] の範囲にクランプされます。

        \[\begin{eqnarray*} \textrm{if } \textrm{steps}[i] > 0: \, \textrm{ends}[i] \in [0, \textrm{dims}[\textrm{axes}[i]]] \end{eqnarray*}\]
      • 負方向ステップの場合: 'ends'"ends" は [-1, dims - 1] の範囲にクランプされます。

        \[\begin{eqnarray*} \textrm{if } \textrm{steps}[i] < 0: \, \textrm{ends}[i] \in [-1, \textrm{dims}[\textrm{axes}[i]] - 1] \end{eqnarray*}\]

以下の一般パラメータ GenParamNamegenParamNamegen_param_name および対応する値 GenParamValuegenParamValuegen_param_value がサポートされています:

  • 'axes_format'"axes_format": 指定されたAxesaxesaxesがWHCN形式(デフォルト)で与えられるか、NCHW形式で与えられるかを決定する互換性パラメータです。 このパラメータは、指定された軸がどのように解釈されるかを変更します。 たとえば、軸11と'axes_format'"axes_format"が'nchw'"nchw"の場合、スライスは深度に沿って実行されます。 'axes_format'"axes_format"が'whcn'"whcn"に設定されているか、指定されていない場合、スライスは高さに沿って実行されます。 インデックスの代わりに、文字列を使用して軸を指定することもできます。

    値のリスト: 'nchw'"nchw", 'whcn'"whcn"

    初期値: 'whcn'"whcn"

  • 'is_inference_output'"is_inference_output": apply_dl_modelApplyDlModel が、この層を Outputsoutputsoutputs に 明示的に指定していなくても、出力を辞書 DLResultBatchDLResultBatchdlresult_batch に 含めるかどうかを決定します('true'"true" の場合は含め、'false'"false" の場合は含めません)。

    値のリスト: 'true'"true", 'false'"false"

    初期値: 'false'"false"

このオペレータ create_dl_layer_sliceCreateDlLayerSlice によって 作成された層の特定のパラメータは、他のオペレータを使用して設定および 取得することができます。 以下の表は、どのパラメータが 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
'input_layer'"input_layer" (DLLayerInputDLLayerInputdllayer_input) x
'name'"name" (LayerNamelayerNamelayer_name) x x
'axes'"axes" x
'starts'"starts" x
'ends'"ends" x
'steps'"steps" x
'output_layer'"output_layer" (DLLayerSliceDLLayerSlicedllayer_slice) x
'shape'"shape" x
'type'"type" x
汎用層パラメータ set get
'is_inference_output'"is_inference_output" x x
'num_trainable_params'"num_trainable_params" x

実行情報🔗

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

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

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

パラメーター🔗

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

入力される層

初期値: 'DLLayerInput'"DLLayerInput"

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

出力層の名前

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

スライスに使用する軸

初期値: 00
推奨値: 0, 'width', 1, 'height', 2, 'depth'0, "width", 1, "height", 2, "depth"

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

対応する軸に対する開始インデックス(含む)

初期値: 00

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

対応する軸に対する終了インデックス(含まない)

初期値: 11

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

スライスステップ

初期値: [][]

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

汎用入力パラメータ名

初期値: [][]
値のリスト: 'axes_format', 'is_inference_output'"axes_format", "is_inference_output"

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)

汎用入力パラメータ値

初期値: [][]
推奨値: 'true', 'false', 'nchw', 'whcn'"true", "false", "nchw", "whcn"

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

出力層

モジュール🔗

Deep Learning Professional