mindspore.numpy.concatenate

mindspore.numpy.concatenate(arrays, axis=0)[源代码]

Joins a sequence of tensors along an existing axis.

说明

To match Numpy behaviour, \(axis >= 32\) will not cause value error, the axis will be treated as None instead.

参数
  • arrays (Union[Tensor, tuple(Tensor), list(Tensor)]) – a tensor or a list of tensors to be concatenated.

  • axis (Union[None, int], optional) – The axis along which the tensors will be joined, if axis is None, tensors are flattened before use. Default is 0.

返回

A tensor concatenated from a tensor or a list of tensors.

异常
  • TypeError – If input arguments have types not specified above.

  • ValueError – If axis is not in the range of \([-ndim, ndim-1]\), and less than 32.

Supported Platforms:

Ascend GPU CPU

样例

>>> import mindspore.numpy as np
>>> x1 = np.ones((1,2,3))
>>> x2 = np.ones((1,2,1))
>>> x = np.concatenate((x1, x2), axis=-1)
>>> print(x.shape)
(1, 2, 4)