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

View Source On Gitee
mindspore.ops.avg_pool1d(input_x, kernel_size=1, stride=1, padding=0, ceil_mode=False, count_include_pad=True)[source]

Applies a 1D average pooling over an input Tensor which can be regarded as a composition of 1D input planes.

Typically the input is of shape (Nin,Cin,Lin), avg_pool1d outputs regional average in the (Lin)-dimension. Given kernel size ks=lker and stride s=s0, the operation is as follows.

output(Ni,Cj,l)=1lkern=0lker1input(Ni,Cj,s0×l+n)

Warning

kernel_size is in the range [1, 255]. stride is in the range [1, 63].

Parameters
  • input_x (Tensor) – Tensor of shape (N,Cin,Lin).

  • kernel_size (int) – The size of kernel window used to take the average value. Default: 1 .

  • stride (Union(int, tuple[int])) – The distance of kernel moving. stride can either be an int number or a tuple of one int number. Default: 1 .

  • padding (Union(int, tuple[int])) – The pad value to be filled. padding can either be an integer or a tuple of one integer. Default: 0 .

  • ceil_mode (bool) – If True, apply ceil instead of floor to compute the output shape. Default: False.

  • count_include_pad (bool) – If True, include the zero-padding in the averaging calculation. Default: True .

Returns

Tensor of shape (N,Cout,Lout).

Raises
  • TypeError – If input_x is not a Tensor.

  • TypeError – If kernel_size or stride is not an int.

  • TypeError – If ceil_mode or count_include_pad is not a bool.

  • ValueError – If length of shape of input_x is not equal to 3.

  • ValueError – If kernel_size or stride is less than 1.

  • ValueError – If padding is not int nor a tuple whose length is equal to 2.

  • ValueError – If value(s) of padding is less than 0.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> input_x = Tensor(np.random.randint(0, 10, [1, 3, 6]), mindspore.float32)
>>> output = ops.avg_pool1d(input_x, kernel_size=6, stride=1)
>>> print(output.shape)
(1, 3, 1)