Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

mindspore.ops.affine_grid

mindspore.ops.affine_grid(theta, size, align_corners=False)[source]

Returns a 2D or 3D flow field (sampling grid) based on theta, a batch of affine matrices.

Parameters
  • theta (Tensor) – The input tensor of flow field whose dtype is float16, float32. Input batch of affine matrices with shape (N,2,3) for 2D grid or (N,3,4) for 3D grid.

  • size (tuple[int]) – The target output image size. The value of target output with format (N,C,H,W) for 2D grid or (N,C,D,H,W) for 3D grid.

  • align_corners (bool, optional) – Geometrically, each pixel of input is viewed as a squqre instead of dot. If True , consider extremum -1 and 1 referring to the centers of the pixels rather than pixel corners. The default value is False , extremum -1 and 1 refer to the corners of the pixels, so that sampling is irrelevant to resolution of the image. Default: False .

Returns

Tensor, a tensor whose data type is same as 'theta', and the shape is (N,H,W,2) for 2D grid or (N,D,H,W,3) for 3D grid.

Raises
  • TypeError – If theta is not a Tensor or size is not a tuple.

  • ValueError – If the shape of theta is not (N,2,3) or (N,3,4).

  • ValueError – If the size of size is not 4 or 5.

  • ValueError – If the shape of theta is (N,2,3), the size of size is not 4; If the shape of theta is (N,3,4), the size of size is not 5.

  • ValueError – If the size[0] is not equal to the shape[0] of theta.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> from mindspore import Tensor
>>> from mindspore import ops
>>> theta = Tensor([[[0.8, 0.5, 0],[-0.5, 0.8, 0]]], mindspore.float32)
>>> out_size = (1, 3, 2, 3)
>>> output = ops.affine_grid(theta, out_size, False)
>>> print(output)
[[[[-0.78333336 -0.06666666]
[-0.25       -0.4       ]
[ 0.28333336 -0.73333335]]
[[-0.28333336  0.73333335]
[ 0.25        0.4       ]
[ 0.78333336  0.06666666]]]]