Skip to content

create_dl_layer_grid_sampleCreateDlLayerGridSampleCreateDlLayerGridSamplecreate_dl_layer_grid_sampleT_create_dl_layer_grid_sample🔗

説明🔗

create_dl_layer_grid_sampleCreateDlLayerGridSampleCreateDlLayerGridSamplecreate_dl_layer_grid_sampleT_create_dl_layer_grid_sample — グリッドサンプル層を作成します。

書式🔗

create_dl_layer_grid_sample( dl_layer DLLayerInput, dl_layer DLLayerGrid, string LayerName, attribute.name GenParamName, attribute.value GenParamValue, out dl_layer DLLayerGridSample )void CreateDlLayerGridSample( const HTuple& DLLayerInput, const HTuple& DLLayerGrid, const HTuple& LayerName, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* DLLayerGridSample )static void HOperatorSet.CreateDlLayerGridSample( HTuple DLLayerInput, HTuple DLLayerGrid, HTuple layerName, HTuple genParamName, HTuple genParamValue, out HTuple DLLayerGridSample )def create_dl_layer_grid_sample( dllayer_input: HHandle, dllayer_grid: HHandle, layer_name: str, gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[Union[int, float, str]] ) -> HHandle

Herror T_create_dl_layer_grid_sample( const Htuple DLLayerInput, const Htuple DLLayerGrid, const Htuple LayerName, const Htuple GenParamName, const Htuple GenParamValue, Htuple* DLLayerGridSample )

HDlLayer HDlLayer::CreateDlLayerGridSample( const HDlLayer& DLLayerGrid, const HString& LayerName, const HTuple& GenParamName, const HTuple& GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerGridSample( const HDlLayer& DLLayerGrid, const HString& LayerName, const HString& GenParamName, const HString& GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerGridSample( const HDlLayer& DLLayerGrid, const char* LayerName, const char* GenParamName, const char* GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerGridSample( const HDlLayer& DLLayerGrid, const wchar_t* LayerName, const wchar_t* GenParamName, const wchar_t* GenParamValue ) const (Windows only)

HDlLayer HDlLayer.CreateDlLayerGridSample( HDlLayer DLLayerGrid, string layerName, HTuple genParamName, HTuple genParamValue )

HDlLayer HDlLayer.CreateDlLayerGridSample( HDlLayer DLLayerGrid, string layerName, string genParamName, string genParamValue )

説明🔗

オペレーター create_dl_layer_grid_sampleCreateDlLayerGridSample は、入力画像または特徴マップに 空間変換を適用するグリッドサンプル層を作成します。 作成されたグリッドサンプル層のハンドルは DLLayerGridSampleDLLayerGridSampledllayer_grid_sample に返されます。

グリッドサンプル層は、サンプリンググリッド DLLayerGridDLLayerGriddllayer_grid に基づいて入力 DLLayerInputDLLayerInputdllayer_input をワープ(変形)します。 このグリッドは空間的に正規化された入力ピクセル位置を指定する必要があり、 これらの位置が出力値の補間に使用されます。入力画像または特徴マップ内のピクセル位置は、 値が \([-1, 1]\) の範囲にある必要があります。 したがって、\(x=-1\), \(y=-1\) は左上のピクセル、 \(x=1\), \(y=1\) は右下のピクセルに対応します。 つまり、最大値または最小値の極値は、四隅のピクセル中心位置に対応します。 なお、グリッドサンプル層は内部的に ‘align_corners’ を 11 に設定し、 ピクセルの中心をグリッドの基準点とします。 サンプリンググリッド DLLayerGridDLLayerGriddllayer_grid は、create_dl_layer_affine_gridCreateDlLayerAffineGrid を使用して生成されます。

グリッドサンプル層は出力値を計算するためにバイリニア補間を使用し、 ピクセル値間の滑らかな遷移を確保します。 入力画像または特徴マップの外側にあるサンプリンググリッドの位置に対しては、 該当する値は0に設定されます。 グリッドサンプル層の出力は、入力グリッドと同じ空間次元を持ちます。

パラメータ LayerNamelayerNamelayer_name は、層に個別の名前を設定します。 create_dl_modelCreateDlModel を使用してモデルを作成する場合、 各層は個別の名前を持つ必要がある点に注意してください。

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

  • '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_grid_sampleCreateDlLayerGridSample によって作成された層の特定のパラメータは、 他のオペレータによって設定および取得できます。 以下の表は、どのパラメータが 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, DLLayerGridDLLayerGriddllayer_grid) x
'name'"name" (LayerNamelayerNamelayer_name) x x
'output_layer'"output_layer" (DLLayerGridSampleDLLayerGridSampledllayer_grid_sample) 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)

画像または特徴マップの入力層

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

サンプリンググリッドを定義する入力層

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

出力層の名前

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

汎用入力パラメータ名

初期値: [][]
値のリスト: 'is_inference_output'"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'"true", "false"

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

グリッドサンプル層

例🔗

(HDevelop)


read_image (Image, 'printer_chip/printer_chip_01')
convert_image_type (Image, Image, 'real')
get_image_size (Image, Width, Height)
* Create input layer for the image to be transformed.
create_dl_layer_input ('image', [Width,Height,1], [], [], DLLayerInputImage)
*
* Create an affine grid layer and define the size of its output grid with (Width/2, Height/2), which later
* determines the output image size.
create_dl_layer_input ('transformation', [3,2,1], [], [], DLLayerInputTransformation)
create_dl_layer_affine_grid (DLLayerInputTransformation, 'affine_grid', Width/2, Height/2, [], [], DLLayerAffineGrid)
*
* Create an affine transformation which represents a translation
* to the right by half the image width.
* As the affine grid layer uses normalized pixel positions in
* the range of [-1,1] the translation value must be normalized
* as well. Hence, translating by half the image width to the right
* corresponds to a translation value of -1 in x-direction.
hom_mat2d_identity (HomMat2DIdentity)
hom_mat2d_translate (HomMat2DIdentity, -1, 0, HomMat2DTranslate)
*
* Create grid sample layer with the affine grid as input
create_dl_layer_grid_sample (DLLayerInputImage, DLLayerAffineGrid, 'output', [], [], DLLayerGridSample)
*
* Create and apply dl model
create_dl_model (DLLayerGridSample, DLModelHandle)
DLSample := dict{image: Image, transformation: HomMat2DTranslate}
apply_dl_model (DLModelHandle, DLSample, [], DLResultBatch)
get_dict_object (ImageTranslated, DLResultBatch, 'output')

他のオペレーターとの組み合わせ🔗

組み合わせ

前処理の候補

create_dl_layer_affine_gridCreateDlLayerAffineGrid

モジュール🔗

Deep Learning Professional