mindspore/docs/api/api_python/ops/mindspore.ops.func_concat.rst

28 lines
1.6 KiB
ReStructuredText
Raw Normal View History

mindspore.ops.concat
====================
.. py:function:: mindspore.ops.concat(input_x, axis=0)
在指定轴上拼接输入Tensor。
输入的是一个tuple或list。其元素秩相同:math:`R` 。将给定的轴设为 `m` ,并且 :math:`0 \le m < R` 。输入元素的数量设为 :math:`N` 。对于第 :math:`i` 个数据, :math:`t_i` 的shape为 :math:`(x_1, x_2, ..., x_{mi}, ..., x_R)`:math:`x_{mi}` 是第 :math:`i` 个元素的第 :math:`m` 个维度。则输出tensor的shape为
.. math::
(x_1, x_2, ..., \sum_{i=1}^Nx_{mi}, ..., x_R)
.. note::
`axis` 的取值范围为 :math:`[-dims, dims - 1]``dims``input_x` 的维度长度。
2022-07-25 15:09:45 +08:00
参数:
- **input_x** (tuple, list) - 输入为Tensor组成的tuple或list。假设在这个tuple或list中有两个Tensor`x1``x2` 。要在0轴方向上执行 `Concat` 除0轴外其他轴的shape都应相等:math:`x1.shape[1] = x2.shape[1]x1.shape[2] = x2.shape[2]...x1.shape[R] = x2.shape[R]` ,其中 :math:`R` 表示最后一个轴。
2022-08-10 16:10:11 +08:00
- **axis** (int) - 表示指定的轴,取值范围是 :math:`[-R, R)` 。默认值0。
2022-07-25 15:09:45 +08:00
返回:
Tensorshape为 :math:`(x_1, x_2, ..., \sum_{i=1}^Nx_{mi}, ..., x_R)` 。数据类型与 `input_x` 相同。
异常:
- **TypeError** - `axis` 不是int。
- **ValueError** - `input_x` 是不同维度的Tensor。
2022-08-10 16:10:11 +08:00
- **ValueError** - `axis` 的值不在区间 :math:`[-R, R)` 内。
2022-07-25 15:09:45 +08:00
- **RuntimeError** - 除了 `axis` 之外, `input_x` 的shape不相同。