create_dl_layer_grid_sample🔗
説明🔗
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 )
説明🔗
オペレーター create_dl_layer_grid_sample は、入力画像または特徴マップに
空間変換を適用するグリッドサンプル層を作成します。
作成されたグリッドサンプル層のハンドルは
DLLayerGridSample に返されます。
グリッドサンプル層は、サンプリンググリッド DLLayerGrid
に基づいて入力 DLLayerInput をワープ(変形)します。
このグリッドは空間的に正規化された入力ピクセル位置を指定する必要があり、
これらの位置が出力値の補間に使用されます。入力画像または特徴マップ内のピクセル位置は、
値が \([-1, 1]\) の範囲にある必要があります。
したがって、\(x=-1\), \(y=-1\) は左上のピクセル、
\(x=1\), \(y=1\) は右下のピクセルに対応します。
つまり、最大値または最小値の極値は、四隅のピクセル中心位置に対応します。
なお、グリッドサンプル層は内部的に ‘align_corners’ を 1 に設定し、
ピクセルの中心をグリッドの基準点とします。
サンプリンググリッド DLLayerGrid は、create_dl_layer_affine_grid
を使用して生成されます。
グリッドサンプル層は出力値を計算するためにバイリニア補間を使用し、 ピクセル値間の滑らかな遷移を確保します。 入力画像または特徴マップの外側にあるサンプリンググリッドの位置に対しては、 該当する値は0に設定されます。 グリッドサンプル層の出力は、入力グリッドと同じ空間次元を持ちます。
パラメータ LayerName は、層に個別の名前を設定します。
create_dl_model を使用してモデルを作成する場合、
各層は個別の名前を持つ必要がある点に注意してください。
以下の汎用パラメータ GenParamName および対応する値
GenParamValue がサポートされています:
-
'is_inference_output': オペレータ
apply_dl_modelがOutputsでこの層を 指定していない場合であっても、ディクショナリDLResultBatchに、 この層の出力を含む('true')か、含まない('false')かを決定します。 値のリスト: 'true', 'false'初期値: 'false'
この create_dl_layer_grid_sample によって作成された層の特定のパラメータは、
他のオペレータによって設定および取得できます。
以下の表は、どのパラメータが set_dl_model_layer_param によって設定でき、
どのパラメータが get_dl_model_layer_param または get_dl_layer_param に
よって取得できるかの概要を示しています。
set_dl_model_layer_param および get_dl_model_layer_param を使用するには、
create_dl_model によって作成されたモデルが必要です。
| 層パラメータ | set |
get |
|---|---|---|
'input_layer' (DLLayerInput, DLLayerGrid) |
x |
|
'name' (LayerName) |
x |
x |
'output_layer' (DLLayerGridSample) |
x |
|
| 'shape' | x |
|
| 'type' | x |
| 汎用層パラメータ | set |
get |
|---|---|---|
| 'is_inference_output' | x |
x |
| 'num_trainable_params' | x |
実行情報🔗
実行情報
-
マルチスレッドタイプ: リエントラント(非排他なオペレーターと並列に動作)
-
マルチスレッドスコープ: グローバル(他のスレッドから呼び出される可能性あり)
-
並列演算処理には未対応
パラメーター🔗
DLLayerInput (input_control) dl_layer → (handle)
画像または特徴マップの入力層
DLLayerGrid (input_control) dl_layer → (handle)
サンプリンググリッドを定義する入力層
LayerName (input_control) string → (string)
出力層の名前
GenParamName (input_control) attribute.name(-array) → (string)
汎用入力パラメータ名
初期値: []
値のリスト: 'is_inference_output'
GenParamValue (input_control) attribute.value(-array) → (string / integer / real)
汎用入力パラメータ値
初期値: []
推奨値: 'true', 'false'
DLLayerGridSample (output_control) dl_layer → (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')
他のオペレーターとの組み合わせ🔗
モジュール🔗
Deep Learning Professional