maxframe.tensor.ndim#

maxframe.tensor.ndim(a)[source]#

Return the number of dimensions of a tensor.

Parameters:

a (array_like) – Input tebsir. If it is not already a tensor, a conversion is attempted.

Returns:

number_of_dimensions – The number of dimensions in a. Scalars are zero-dimensional.

Return type:

int

See also

ndarray.ndim

equivalent method

shape

dimensions of tensor

Tensor.shape

dimensions of tensor

Examples

>>> import maxframe.tensor as mt
>>> mt.ndim([[1,2,3],[4,5,6]])
2
>>> mt.ndim(mt.array([[1,2,3],[4,5,6]]))
2
>>> mt.ndim(1)
0