mindspore.Tensor.ndim

property mindspore.Tensor.ndim

返回Tensor维度的数量。

样例:

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