分類目錄:《深入淺出TensorFlow2函數(shù)》總目錄
語(yǔ)法
tf.rank(input, name=None)
參數(shù)
-
input
:tf.Tensor
或tf.SparseTensor
-
name
:[可選] 操作的名稱
返回值
張量input
的維度,是一個(gè)int32
類型的張量
實(shí)例
輸入:文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-529857.html
t = tf.constant([[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]])
tf.rank(t)
輸出:文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-529857.html
<tf.Tensor: shape=(), dtype=int32, numpy=3>
函數(shù)實(shí)現(xiàn)
@tf_export("rank")
@dispatch.add_dispatch_support
def rank(input, name=None):
# pylint: disable=redefined-builtin
"""Returns the rank of a tensor.
See also `tf.shape`.
Returns a 0-D `int32` `Tensor` representing the rank of `input`.
For example:
**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`.
@compatibility(numpy)
Equivalent to np.ndim
@end_compatibility
"""
return rank_internal(input, name, optimize=True)
到了這里,關(guān)于深入淺出TensorFlow2函數(shù)——tf.rank的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!