mindspore.ops.cat

查看源文件
mindspore.ops.cat(tensors, axis=0)[源代码]

在指定轴上拼接输入tensor。

参数:
  • tensors (Union[tuple[Tensor], list[Tensor]]) - 输入tensors。除了指定的拼接轴 axis 之外,其他轴的shape都应相等。

  • axis (int) - 指定轴。默认 0

返回:

Tensor

支持平台:

Ascend GPU CPU

样例:

>>> import mindspore
>>> input_x1 = mindspore.tensor([[0, 1], [2, 1]], mindspore.float32)
>>> input_x2 = mindspore.tensor([[0, 1], [2, 1]], mindspore.float32)
>>> output = mindspore.ops.cat((input_x1, input_x2))
>>> print(output)
[[0. 1.]
 [2. 1.]
 [0. 1.]
 [2. 1.]]
>>> output = mindspore.ops.cat((input_x1, input_x2), 1)
>>> print(output)
[[0. 1. 0. 1.]
 [2. 1. 2. 1.]]