mindspore/docs/api/api_python/ops/mindspore.ops.func_unsqueez...

23 lines
968 B
ReStructuredText
Raw Permalink 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.unsqueeze
=========================
.. py:function:: mindspore.ops.unsqueeze(input_x, dim)
对输入 `input_x` 在给定维上添加额外维度。
扩展后的Tensor中位置对应 `dim` 的维度为插入的新维度。
.. note::
如果指定的 `dim` 是负数那么它会从后往前从1开始计算index。
参数:
- **input_x** (Tensor) - 输入Tensorshape为 :math:`(x_1, x_2, ..., x_R)`
- **dim** (int) - 新插入的维度的位置。 `dim` 的值必须在范围 `[-input_x.ndim-1, input_x.ndim]` 内。仅接受常量输入。
返回:
Tensor维度在指定轴扩展之后的Tensor`input_x` 的数据类型相同。如果 `dim` 是0那么它的shape为 :math:`(1, x_1, x_2, ..., x_R)`
异常:
- **TypeError** - 如果 `dim` 不是int。
- **ValueError** - 如果 `dim` 超出了 :math:`[-input_x.ndim-1, input_x.ndim]` 的范围。