Join the newly launched
Discord community for real-time discussions, peer support, and direct interaction with the Meridian team!
meridian.backend.rank
Stay organized with collections
Save and categorize content based on your preferences.
Returns the rank of a tensor.
meridian.backend.rank(
input, name=None
)
See also tf.shape
.
Returns a 0-D int32
Tensor
representing the rank of input
.
For example:
# 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 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."
Args |
input
|
A Tensor or SparseTensor .
|
name
|
A name for the operation (optional).
|
Returns |
A Tensor of type int32 .
|
Equivalent to np.ndim
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-09-05 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-05 UTC."],[],[],null,[]]