[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.rank\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 1 version](/versions/r1.15/api_docs/python/tf/rank) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.1.0/tensorflow/python/ops/array_ops.py#L672-L703) |\n\nReturns the rank of a tensor.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.rank`](/api_docs/python/tf/rank)\n\n\u003cbr /\u003e\n\n tf.rank(\n input, name=None\n )\n\nReturns a 0-D `int32` `Tensor` representing the rank of `input`.\n\n#### For example:\n\n # shape of tensor 't' is [2, 2, 3]\n t = tf.constant([[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]])\n tf.rank(t) # 3\n\n| **Note:** The rank of a tensor is not the same as the rank of a matrix. The rank of a tensor is the number of indices required to uniquely select each element of the tensor. Rank is also known as \"order\", \"degree\", or \"ndims.\"\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------|--------------------------------------|\n| `input` | A `Tensor` or `SparseTensor`. |\n| `name` | A name for the operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A `Tensor` of type `int32`. ||\n\n\u003cbr /\u003e\n\n#### Numpy Compatibility\n\nEquivalent to np.ndim"]]