mindspore.numpy.concatenate¶

mindspore.numpy.concatenate(arrays, axis=0)[source]

Joins a sequence of tensors along an existing axis.

Note

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

Parameters
• 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.

Returns

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

Raises
• 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

Examples

>>> 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)