codecamp

tf.rank函数:返回TensorFlow张量的秩

tf.rank 函数
rank(
    input,
    name=None
)

定义在:tensorflow/python/ops/array_ops.py.

参见指南:张量转换>形状的确定和改变

返回张量的秩.

返回0维的 int32 Tensor,它表示 input 的秩.

例如:

# 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”.

参数:

  • input:A Tensor或SparseTensor.
  • name:操作的名称(可选).

返回:

int32 类型的 Tensor.

numpy兼容性

相当于np.ndim

tf.range函数:创建数字序列
TensorFlow读取器基类:tf.ReaderBase
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

TensorFlow 函数介绍

TensorFlow 函数模块:tf

TensorFlow的image模块

TensorFlow使用之tf.io

TensorFlow使用之tf.keras

TensorFlow函数教程:tf.keras.applications

TensorFlow函数教程:tf.keras.backend

TensorFlow使用之tf.metrics

TensorFlow使用之tf.nn

TensorFlow使用之tf.python_io

TensorFlow 功能函数

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }