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.Tensor.repeat_interleave

Tensor.repeat_interleave(repeats, dim=None, *, output_size=None) Tensor

Repeat elements of a tensor along a dim, like mindspore.numpy.repeat().

Warning

Only support on Atlas A2 training series.

Note

The self tensor to repeat values for. Must be of type: float16, float32, int8, uint8, int16, int32, or int64.

Parameters
  • repeats (Union[int, tuple, list, Tensor]) – The number of times to repeat, must be positive.

  • dim (int, optional) – The dim along which to repeat, Default: None. if dim is None, the self Tensor will be flattened and the output will alse be flattened.

Keyword Arguments

output_size (int, optional) – Total output size for the given axis (e.g. sum of repeats), Default: None.

Returns

One tensor with values repeated along the specified dim. If self has shape (s1,s2,...,sn) and dim is i, the output will have shape (s1,s2,...,sirepeats,...,sn). The output type will be the same as the type of self.

Supported Platforms:

Ascend

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor
>>> input1 = Tensor(np.array([[0, 1, 2], [3, 4, 5]]), mindspore.int32)
>>> output1 = input1.repeat_interleave(repeats=2, dim=0, output_size=None)
>>> input2 = Tensor(np.array([[1, 2], [3, 4]]), mindspore.int32)
>>> output2 = input2.repeat_interleave(Tensor(np.array([1, 2])), dim=0, output_size=None)
>>> print(output1)
>>> print(output2)
[[0 1 2]
 [0 1 2]
 [3 4 5]
 [3 4 5]]
[[1 2]
 [3 4]
 [3 4]]
Tensor.repeat_interleave(repeats, dim=None) Tensor

Repeat elements of a tensor along an dim, like mindspore.numpy.repeat().

Note

The tensor to repeat values for. Must be of type: float16, float32, int8, uint8, int16, int32, or int64.

Parameters
  • repeats (Union[int, tuple, list, Tensor]) – The number of times to repeat, must be positive.

  • dim (int, optional) – The dim along which to repeat, Default: None. if dim is None, the self Tensor will be flattened and the output will alse be flattened.

Returns

One tensor with values repeated along the specified dim. If self has shape (s1,s2,...,sn) and dim is i, the output will have shape (s1,s2,...,sirepeats,...,sn). The output type will be the same as the type of self.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor
>>> input1 = Tensor(np.array([[0, 1, 2], [3, 4, 5]]), mindspore.int32)
>>> output1 = input1.repeat_interleave(repeats=2, dim=0)
>>> input2 = Tensor(np.array([[1, 2], [3, 4]]), mindspore.int32)
>>> output2 = input2.repeat_interleave(Tensor(np.array([1, 2])), dim=0)
>>> print(output1)
>>> print(output2)
[[0 1 2]
 [0 1 2]
 [3 4 5]
 [3 4 5]]
[[1 2]
 [3 4]
 [3 4]]