mindspore.ops.Concat
- class mindspore.ops.Concat(*args, **kwargs)[source]
Connect tensor in the specified axis.
Connect input tensors along with the given axis.
The input data is a tuple of tensors. These tensors have the same rank R. Set the given axis as m, and \(0 \le m < R\). Set the number of input tensors as N. For the \(i\)-th tensor \(t_i\), it has the shape of \((x_1, x_2, ..., x_{mi}, ..., x_R)\). \(x_{mi}\) is the \(m\)-th dimension of the \(i\)-th tensor. Then, the shape of the output tensor is
\[(x_1, x_2, ..., \sum_{i=1}^Nx_{mi}, ..., x_R)\]- Parameters
axis (int) – The specified axis. Default: 0.
- Inputs:
input_x (tuple, list) - A tuple or a list of input tensors.
- Outputs:
Tensor, the shape is \((x_1, x_2, ..., \sum_{i=1}^Nx_{mi}, ..., x_R)\).
- Raises
TypeError – If axis is not an int.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> data1 = Tensor(np.array([[0, 1], [2, 1]]).astype(np.float32)) >>> data2 = Tensor(np.array([[0, 1], [2, 1]]).astype(np.float32)) >>> op = ops.Concat() >>> output = op((data1, data2)) >>> print(output) [[0. 1.] [2. 1.] [0. 1.] [2. 1.]]