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.ScaleAndTranslate

class mindspore.ops.ScaleAndTranslate(kernel_type='lanczos3', antialias=True)[source]

Scale And Translate the input image tensor.

Note

  • Input images must be a 4-D tensor.

  • Input size, scale and translation must be a 1-D tensor with two elements.

Parameters
  • kernel_type (str, optional) – Deciding which image filtering algorithm to choose. Valid options: [“lanczos1”, “lanczos3”, “lanczos5”, “gaussian”, “box”, “triangle”, “keyscubic”, “mitchellcubic”] Default: “lanczos3”.

  • antialias (bool, optional) – Deciding whether to use the antialias. Default: True.

Inputs:
  • images (Tensor) - A 4-D tensor of shape (batch,image_height,image_width,channel).

  • size (Tensor) - The size of the output image after scale and translate operations. A 1-D tensor with two positive elements whose dtype is int32 and shape must be (2,).

  • scale (Tensor) - Indicates the zoom factor. A 1-D tensor with two positive elements whose dtype is float32 and shape must be (2,).

  • translation (Tensor) - Translate the pixel value. A 1-D tensor with two elements whose dtype is float32 and shape must be (2,).

Outputs:

A 4-D tensor with type: float32 and shape (batch,size[0],size[1],channel).

Raises
  • TypeError – If kernel_type is not str.

  • TypeError – If antialias is not bool.

  • TypeError – If images is not tensor with valid dtype.

  • TypeError – If size is not a tensor of int32.

  • TypeError – If scale is not a tensor of float32.

  • TypeError – If translation is not a tensor of float32.

  • ValueError – If kernel_type is not in [“lanczos1”, “lanczos3”, “lanczos5”, “gaussian”, “box”, “triangle”, “keyscubic”, “mitchellcubic”].

  • ValueError – If the rank of images is not 4.

  • ValueError – If the shape of size is not (2,).

  • ValueError – If the shape of scale is not (2,).

  • ValueError – If the shape of translation is not (2,).

Supported Platforms:

GPU CPU

Examples

>>> op = ops.ScaleAndTranslate()
>>> image = Tensor(np.array([[[[9.0], [5.0], [2.0], [1.0]],
...                           [[6.0], [1.0], [9.0], [7.0]]]]), mindspore.float32)
>>> size = Tensor(np.array([2, 2]).astype(np.int32))
>>> scale = Tensor(np.array([1, 1]).astype(np.float32))
>>> translation = Tensor(np.array([1, 1]).astype(np.float32))
>>> output = op(image, size, scale, translation)
>>> print(output)
[[[[0.]
   [0.]]
  [[0.]
   [9.]]]]