mindspore.Tensor.ndim

property Tensor.ndim

Return the number of tensor dimensions.

Examples

>>> from mindspore import Tensor
>>> import numpy as np
>>> x = Tensor(np.array([[1, 2], [3, 4]]))
>>> output = x.ndim
>>> print(output)
2