MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / rank

Function rank

tensorflow/python/ops/array_ops.py:577–606  ·  view source on GitHub ↗

Returns the rank of a tensor. Returns a 0-D `int32` `Tensor` representing the rank of `input`. For example: ```python # shape of tensor 't' is [2, 2, 3] t = tf.constant([[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]]) tf.rank(t) # 3 ``` **Note**: The rank of a tensor is not the

(input, name=None)

Source from the content-addressed store, hash-verified

575@tf_export("rank")
576@dispatch.add_dispatch_support
577def rank(input, name=None):
578 # pylint: disable=redefined-builtin
579 """Returns the rank of a tensor.
580
581 Returns a 0-D `int32` `Tensor` representing the rank of `input`.
582
583 For example:
584
585 ```python
586 # shape of tensor 't' is [2, 2, 3]
587 t = tf.constant([[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]])
588 tf.rank(t) # 3
589 ```
590
591 **Note**: The rank of a tensor is not the same as the rank of a matrix. The
592 rank of a tensor is the number of indices required to uniquely select each
593 element of the tensor. Rank is also known as "order", "degree", or "ndims."
594
595 Args:
596 input: A `Tensor` or `SparseTensor`.
597 name: A name for the operation (optional).
598
599 Returns:
600 A `Tensor` of type `int32`.
601
602 @compatibility(numpy)
603 Equivalent to np.ndim
604 @end_compatibility
605 """
606 return rank_internal(input, name, optimize=True)
607
608
609def rank_internal(input, name=None, optimize=True):

Callers 7

matrix_transposeFunction · 0.70
_all_dimensionsFunction · 0.70
_batch_gatherFunction · 0.70
batch_gather_ndFunction · 0.70
repeat_with_axisFunction · 0.70
tile_one_dimensionFunction · 0.70
_with_nonzero_rankFunction · 0.70

Calls 1

rank_internalFunction · 0.85

Tested by

no test coverage detected