rank

paddle. rank ( input ) [source]

Returns the number of dimensions for a tensor, which is a 0-D int32 Tensor.

Parameters

input (Tensor) – The input Tensor with shape of \([N_1, N_2, ..., N_k]\), the data type is arbitrary.

Returns

The 0-D tensor with the dimensions of the input Tensor.

Return type

Tensor, the output data type is int32.

Examples

>>> import paddle

>>> input = paddle.rand((3, 100, 100))
>>> rank = paddle.rank(input)
>>> print(rank.numpy())
3