codecamp

TensorFlow函数:tf.metrics.precision_at_top_k

tf.metrics.precision_at_top_k函数

tf.metrics.precision_at_top_k(
    labels,
    predictions_idx,
    k=None,
    class_id=None,
    weights=None,
    metrics_collections=None,
    updates_collections=None,
    name=None
)

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

计算与稀疏labels相关的predictions的精度@ k.

与sparse_precision_at_k不同之处在于,predictions必须采用顶级k索引的形式,而sparse_precision_at_k期望是logits.

参数:

  • labels:具有形状[D1,... DN,num_labels]或[D1,... DN]的int64 Tensor或SparseTensor,其中后者暗示num_labels = 1.N> = 1并且num_labels是关联预测的目标类的数量.通常,N = 1并且labels具有形状[batch_size,num_labels].[D1,... DN]必须匹配predictions.值应在[0,num_classes]范围内,其中num_classes是predictions的最后一个维度.超出此范围的值将被忽略.
  • predictions_idx:具有形状[D1,... DN,k]的整数Tensor,其中N> = 1.通常,N = 1并且predictions具有形状[batch size, k].最终维度包含最高k预测类别索引.[D1,... DN]必须匹配labels.
  • k:整数,k代表@k metric.仅用于默认操作名称.
  • class_id:我们需要二进制度量的整数类ID.这应该在[0,num_classes]范围内,其中num_classes是predictions的最后一个维度.如果class_id超出此范围,则该方法返回NAN.
  • weights:Tensor,其秩为0或n-1,其中n是labels的秩.如果是后者,则必须是可广播的labels(即,所有维度必须为1或者与相应的labels维度相同).
  • metrics_collections:应添加值的集合可选的列表.
  • updates_collections:应添加更新的集合可选的列表.
  • name:新更新操作的名称,以及其他从属操作的命名空间.

返回:

  • precision:标量float64 Tensor,其值为:true_positives除以true_positives和false_positives的和.
  • update_op:适当增加true_positives和false_positives变量的操作,其值匹配precision.

可能引发的异常:

  • ValueError:如果weights不是None和它的形状与predictions不匹配,或者如果metrics_collections或updates_collections中任意一个不是一个列表或元组.
  • RuntimeError:如果启用了急切执行.
TensorFlow函数:tf.metrics.precision_at_thresholds
TensorFlow函数:tf.metrics.recall
温馨提示
下载编程狮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; }