You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mindspore.ops.Squeeze.rst 1.6 kB

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