mindspore2022/docs/api/api_python/ops/mindspore.ops.Squeeze.rst

34 lines
1.5 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.ops.Squeeze
=====================
.. py:class:: mindspore.ops.Squeeze(axis=())
返回删除指定 `axis` 中大小为1的维度后的Tensor。
如果 :math:`axis=()` 则删除所有大小为1的维度。
如果指定了 `axis`,则删除指定 `axis` 中大小为1的维度。
例如,如果不指定维度 :math:`axis=()` 输入的shape为(A, 1, B, C, 1, D)则输出的Tensor的shape为(A, B, C, D)如果指定维度squeeze操作仅在指定维度中进行。
如果输入的shape为(A, 1, B) `axis` 设置为0时不会改变输入的Tensor`axis` 设置为1时会使输入Tensor的shape变为(A, B)。
.. note::
- 请注意在动态图模式下输出Tensor将与输入Tensor共享数据并且没有Tensor数据复制过程。
- 维度索引从0开始并且必须在 `[-input_x.ndim, input_x.ndim)` 范围内。
**参数:**
**axis** (Union[int, tuple(int)]) - 指定待删除shape的维度索引它会删除给定axis参数中所有大小为1的维度。如果指定了维度索引其数据类型必须为int32或int64。默认值()空tuple。
**输入:**
**input_x** (Tensor) - 用于计算Squeeze的输入Tensorshape为 :math:`(x_1, x_2, ..., x_R)`
**输出:**
Tensorshape为 :math:`(x_1, x_2, ..., x_S)`
**异常:**
- **TypeError** - `axis` 既不是int也不是tuple。
- **TypeError** - `axis` 是tuple其元素并非全部是int。
- **ValueError** - 指定 `axis` 的对应维度不等于1。