tf.rank()

import tensorflow as tf
# 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

  • 张量的秩与矩阵的秩不一样.张量的秩是唯一选择张量的每个元素所需的索引的数量.可以理解为维度秩也被称为 “order”,“degree” 或 “ndims”.

posted @ 2022-08-19 22:50  luoganttcc  阅读(13)  评论(0)    收藏  举报