codecamp

TensorFlow函数教程:tf.nn.in_top_k

tf.nn.in_top_k函数

tf.nn.in_top_k(
    predictions,
    targets,
    k,
    name=None
)

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

请参阅指南:神经网络>评估

说明目标是否在前K个预测中.

这输出了一个batch_size bool数组,如果目标类的预测是所有预测(例如i)中的前k个预测,则条目out[i]为true.请注意,InTopK的行为在处理关系时与TopK操作不同;如果多个类具有相同的预测值并跨越top-k边界,则所有这些类都被认为是在前k个.

更具体的介绍:

对于示例i:\(predictions_i \)是所有类的预测,;\(targets_i \)是目标类;\(out_i \)是输出.

$out_i = predictions_{i, targets_i} \in TopKIncludingTies(predictions_i)$

参数:

  • predictions:float32类型的Tensor.batch_size x classes张量.
  • targets:一个Tensor,必须是以下类型之一:int32,int64.类ids的batch_size向量.
  • k:int类型,要计算精度的顶级元素数.
  • name:操作的名称(可选).

返回:

bool类型的Tensor.以bool Tensor计算k处的精度.

TensorFlow函数教程:tf.nn.fused_batch_norm
TensorFlow函数教程:tf.nn.l2_loss
温馨提示
下载编程狮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; }