Operator Reference

create_dl_layer_affine_gridT_create_dl_layer_affine_gridCreateDlLayerAffineGridCreateDlLayerAffineGridcreate_dl_layer_affine_grid (Operator)

create_dl_layer_affine_gridT_create_dl_layer_affine_gridCreateDlLayerAffineGridCreateDlLayerAffineGridcreate_dl_layer_affine_grid — Create an affine grid layer.

Signature

Herror T_create_dl_layer_affine_grid(const Htuple DLLayerInput, const Htuple LayerName, const Htuple Width, const Htuple Height, const Htuple GenParamName, const Htuple GenParamValue, Htuple* DLLayerAffineGrid)

void CreateDlLayerAffineGrid(const HTuple& DLLayerInput, const HTuple& LayerName, const HTuple& Width, const HTuple& Height, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* DLLayerAffineGrid)

HDlLayer HDlLayer::CreateDlLayerAffineGrid(const HString& LayerName, Hlong Width, Hlong Height, const HTuple& GenParamName, const HTuple& GenParamValue) const

HDlLayer HDlLayer::CreateDlLayerAffineGrid(const HString& LayerName, Hlong Width, Hlong Height, const HString& GenParamName, const HString& GenParamValue) const

HDlLayer HDlLayer::CreateDlLayerAffineGrid(const char* LayerName, Hlong Width, Hlong Height, const char* GenParamName, const char* GenParamValue) const

HDlLayer HDlLayer::CreateDlLayerAffineGrid(const wchar_t* LayerName, Hlong Width, Hlong Height, const wchar_t* GenParamName, const wchar_t* GenParamValue) const   ( Windows only)

static void HOperatorSet.CreateDlLayerAffineGrid(HTuple DLLayerInput, HTuple layerName, HTuple width, HTuple height, HTuple genParamName, HTuple genParamValue, out HTuple DLLayerAffineGrid)

HDlLayer HDlLayer.CreateDlLayerAffineGrid(string layerName, int width, int height, HTuple genParamName, HTuple genParamValue)

HDlLayer HDlLayer.CreateDlLayerAffineGrid(string layerName, int width, int height, string genParamName, string genParamValue)

def create_dl_layer_affine_grid(dllayer_input: HHandle, layer_name: str, width: int, height: int, gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[Union[int, float, str]]) -> HHandle

Description

The operator create_dl_layer_affine_gridcreate_dl_layer_affine_gridCreateDlLayerAffineGridCreateDlLayerAffineGridcreate_dl_layer_affine_grid creates an affine grid layer which returns a 2D sampling grid parameterized by an affine transformation matrix. The handle of the affine grid layer is returned in DLLayerAffineGridDLLayerAffineGridDLLayerAffineGridDLLayerAffineGriddllayer_affine_grid. Usually, sampling grids are fed into grid sample layers to apply affine transformations to images or feature maps, see create_dl_layer_grid_samplecreate_dl_layer_grid_sampleCreateDlLayerGridSampleCreateDlLayerGridSamplecreate_dl_layer_grid_sample.

The parameter DLLayerInputDLLayerInputDLLayerInputDLLayerInputdllayer_input determines the feeding input layer and expects the layer handle as value. The input consists of a batch of 2D affine transformation matrices (Height = 2, Width = 3). They are passed in the format WHC, representing Width, Height, and Channel, where Channel must always be 1. See affine_trans_image_sizeaffine_trans_image_sizeAffineTransImageSizeAffineTransImageSizeaffine_trans_image_size for more information about affine transformations.

The parameter LayerNameLayerNameLayerNamelayerNamelayer_name sets an individual layer name. Note that if creating a model using create_dl_modelcreate_dl_modelCreateDlModelCreateDlModelcreate_dl_model each layer of the created network must have a unique name.

The parameters WidthWidthWidthwidthwidth and HeightHeightHeightheightheight define the output size. Given a batch of N affine transformation input matrices, the affine grid layer returns a batch of sampling grids of dimension (HeightHeightHeightheightheight, WidthWidthWidthwidthwidth, 2) in the format CHW representing Channel, Height, and Width.

For an affine transformation matrix a point in an image of size (WidthWidthWidthwidthwidth, HeightHeightHeightheightheight) is mapped to by

where refers to the column coordinate and to the row coordinate. Hence, for the affine input matrix of a batch ( ), the output tensor values and corresponds to the column and row values and of the point after transformation.

The sampling grid locations are normalized by the spatial dimensions WidthWidthWidthwidthwidth and HeightHeightHeightheightheight to get values in the range of . Thus, the values , correspond to the top-left pixel, while , describe the bottom-right pixel. Thereby, the extrema refer to the center points of the corner pixels.

The following generic parameters GenParamNameGenParamNameGenParamNamegenParamNamegen_param_name and the corresponding values GenParamValueGenParamValueGenParamValuegenParamValuegen_param_value are supported:

'is_inference_output'"is_inference_output""is_inference_output""is_inference_output""is_inference_output":

Determines whether apply_dl_modelapply_dl_modelApplyDlModelApplyDlModelapply_dl_model will include the output of this layer in the dictionary DLResultBatchDLResultBatchDLResultBatchDLResultBatchdlresult_batch even without specifying this layer in OutputsOutputsOutputsoutputsoutputs ('true'"true""true""true""true") or not ('false'"false""false""false""false").

List of values: 'true'"true""true""true""true", 'false'"false""false""false""false"

Default: 'false'"false""false""false""false"

Certain parameters of layers created using this operator create_dl_layer_affine_gridcreate_dl_layer_affine_gridCreateDlLayerAffineGridCreateDlLayerAffineGridcreate_dl_layer_affine_grid can be set and retrieved using further operators. The following tables give an overview, which parameters can be set using set_dl_model_layer_paramset_dl_model_layer_paramSetDlModelLayerParamSetDlModelLayerParamset_dl_model_layer_param and which ones can be retrieved using get_dl_model_layer_paramget_dl_model_layer_paramGetDlModelLayerParamGetDlModelLayerParamget_dl_model_layer_param or get_dl_layer_paramget_dl_layer_paramGetDlLayerParamGetDlLayerParamget_dl_layer_param. Note, the operators set_dl_model_layer_paramset_dl_model_layer_paramSetDlModelLayerParamSetDlModelLayerParamset_dl_model_layer_param and get_dl_model_layer_paramget_dl_model_layer_paramGetDlModelLayerParamGetDlModelLayerParamget_dl_model_layer_param require a model created by create_dl_modelcreate_dl_modelCreateDlModelCreateDlModelcreate_dl_model.

Layer Parameters set get
'input_layer'"input_layer""input_layer""input_layer""input_layer" (DLLayerInputDLLayerInputDLLayerInputDLLayerInputdllayer_input) x
'name'"name""name""name""name" (LayerNameLayerNameLayerNamelayerNamelayer_name) x x
'grid_size'"grid_size""grid_size""grid_size""grid_size" (WidthWidthWidthwidthwidth, HeightHeightHeightheightheight) x
'output_layer'"output_layer""output_layer""output_layer""output_layer" (DLLayerAffineGridDLLayerAffineGridDLLayerAffineGridDLLayerAffineGriddllayer_affine_grid) x
'shape'"shape""shape""shape""shape" x
'type'"type""type""type""type" x
Generic Layer Parameters set get
'is_inference_output'"is_inference_output""is_inference_output""is_inference_output""is_inference_output" x x
'num_trainable_params'"num_trainable_params""num_trainable_params""num_trainable_params""num_trainable_params" x

Execution Information

  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).
  • Multithreading scope: global (may be called from any thread).
  • Processed without parallelization.

Parameters

DLLayerInputDLLayerInputDLLayerInputDLLayerInputdllayer_input (input_control)  dl_layer HDlLayer, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Input layer for a batch of affine transformation matrices of shape [3,2,1].

LayerNameLayerNameLayerNamelayerNamelayer_name (input_control)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Name of the output layer.

WidthWidthWidthwidthwidth (input_control)  number HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Width of the returned grid.

Default: 256

HeightHeightHeightheightheight (input_control)  number HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Height of the returned grid.

Default: 256

GenParamNameGenParamNameGenParamNamegenParamNamegen_param_name (input_control)  attribute.name(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Generic input parameter names.

Default: []

List of values: 'is_inference_output'"is_inference_output""is_inference_output""is_inference_output""is_inference_output"

GenParamValueGenParamValueGenParamValuegenParamValuegen_param_value (input_control)  attribute.value(-array) HTupleMaybeSequence[Union[int, float, str]]HTupleHtuple (string / integer / real) (string / int / long / double) (HString / Hlong / double) (char* / Hlong / double)

Generic input parameter values.

Default: []

Suggested values: 'true'"true""true""true""true", 'false'"false""false""false""false"

DLLayerAffineGridDLLayerAffineGridDLLayerAffineGridDLLayerAffineGriddllayer_affine_grid (output_control)  dl_layer HDlLayer, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Affine grid layer.

Example (HDevelop)

* Create affine grid layer for images of size (3,5).
create_dl_layer_input ('input', [3,2,1], [], [], DLLayerInput)
create_dl_layer_affine_grid (DLLayerInput, 'affine_grid', 5, 3, ['is_inference_output'], ['true'], DLLayerAffineGrid)
*
* Create an affine transformation which represents a translation
* to the right by one pixel.
* As the affine grid layer uses normalized pixel positions in
* the range of [-1,1] the translation value must be normalized
* as well. For Width = 5 the normalized column values are
* [-1, -0.5, 0.0, 0.5, 1.0]. Hence, translating by one pixel
* to the right corresponds to a translation value of 0.5 in
* x-direction.
hom_mat2d_identity (HomMat2DIdentity)
hom_mat2d_translate (HomMat2DIdentity, 0.5, 0, HomMat2DTranslate)
*
* For better visualization add permutation layer to get an
* output image of size (3,5) where the first channel describes
* the transformed (normalized) column coordinates and the second
* channel describes the transformed (normalized) row coordinates.
create_dl_layer_permutation (DLLayerAffineGrid, 'permute', [1,2,0,3], [], [], DLLayerPermutation)
*
* Create and apply dl model
create_dl_model (DLLayerPermutation, DLModelHandle)
DLSample := dict{input: HomMat2DTranslate}
apply_dl_model (DLModelHandle, DLSample, [], DLResultBatch)

Possible Predecessors

create_dl_layer_inputcreate_dl_layer_inputCreateDlLayerInputCreateDlLayerInputcreate_dl_layer_input

Possible Successors

create_dl_layer_grid_samplecreate_dl_layer_grid_sampleCreateDlLayerGridSampleCreateDlLayerGridSamplecreate_dl_layer_grid_sample, create_dl_layer_permutationcreate_dl_layer_permutationCreateDlLayerPermutationCreateDlLayerPermutationcreate_dl_layer_permutation

See also

affine_trans_image_sizeaffine_trans_image_sizeAffineTransImageSizeAffineTransImageSizeaffine_trans_image_size

Module

Deep Learning Professional