mindspore.numpy.atleast_2d
- mindspore.numpy.atleast_2d(*arys)[source]
Reshapes inputs as arrays with at least two dimensions.
Note
In graph mode, returns a tuple of tensor instead of a list of tensors.
- Parameters
*arys (Tensor) – one or more input tensors.
- Returns
Tensor, or list of tensors, each with
a.ndim >= 2
.- Raises
TypeError – if the input is not a tensor.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore.numpy as np >>> a = np.ones((2, 3)) >>> b = np.ones(()) >>> c = np.ones(5) >>> output = np.atleast_2d(a, b, c) >>> print(output) [Tensor(shape=[2, 3], dtype=Float32, value= [[1.00000000e+000, 1.00000000e+000, 1.00000000e+000], [1.00000000e+000, 1.00000000e+000, 1.00000000e+000]]), Tensor(shape=[1, 1], dtype=Float32, value= [[1.00000000e+000]]), Tensor(shape=[1, 5], dtype=Float32, value= [[1.00000000e+000, 1.00000000e+000, 1.00000000e+000, 1.00000000e+000, 1.00000000e+000]])]