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.

PR

Just a small problem.

I can fix it online!

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

View Source On Gitee
mindspore.ops.max_unpool1d(x, indices, kernel_size, stride=None, padding=0, output_size=None)[source]

Computes the inverse of max_pool1d.

max_unpool1d keeps the maximal value and set all position of non-maximal values to zero. Typically the input is of shape (N,C,Hin) or (C,Hin), and the output is of shape (N,C,Hout) or (C,Hout). The operation is as follows.

Hout=(Hin1)×stride[0]2×padding[0]+kernel_size[0]
Parameters
  • x (Tensor) – The input Tensor to invert. Tensor of shape (N,C,Hin) or (C,Hin).

  • indices (Tensor) – Index of maximum value. Tensor of shape must be same with input 'x'. Values of indices must belong to [0,Hin1]. Data type must be in int32 or int64.

  • kernel_size (Union[int, tuple[int]]) – The size of kernel used to take the maximum value.

  • stride (Union[int, tuple[int]]) – The distance of kernel moving, If stride is 0, (0) or None , then stride equal to kernel_size. Default: None , which indicates the moving step is kernel_size .

  • padding (Union[int, tuple[int]]) – The pad value to be filled. Default: 0 .

  • output_size (tuple[int], optional) – The output shape. Default: None . If output_size == (), then the shape of output computed by kernel_size, stride and padding. If output_size != (), then output_size must be (N,C,H) , (C,H) or (H) and output_size must belong to [(N,C,Houtstride[0]),(N,C,Hout+stride[0])].

Returns

Tensor, with shape (N,C,Hout) or (C,Hout), with the same data type with x.

Raises
  • TypeError – If data type of x or indices is not supported.

  • TypeError – If kernel_size, stride or padding is neither an int nor a tuple.

  • ValueError – If numbers in stride, padding (also support 0 and (0)) or kernel_size is not positive.

  • ValueError – If the shapes of x and indices are not equal.

  • ValueError – If x whose length is not 2 or 3.

  • ValueError – If type of output_size is not tuple.

  • ValueError – If output_size whose length is not 0, 2 or 3.

  • ValueError – If output_size is not close to output size computed by attr kernel_size, stride, padding.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> x = Tensor(np.array([[2, 4, 6, 8]]).astype(np.float32))
>>> indices = Tensor(np.array([[1, 3, 5, 7]]).astype(np.int64))
>>> output = ops.max_unpool1d(x, indices, kernel_size =2, stride=2, padding=0)
>>> print(output.asnumpy())
[[0. 2. 0. 4. 0. 6. 0. 8.]]