TensorFlow函数:tf.metrics.recall_at_thresholds

2018-10-18 14:56 更新

tf.metrics.recall_at_thresholds函数

tf.metrics.recall_at_thresholds(
    labels,
    predictions,
    thresholds,
    weights=None,
    metrics_collections=None,
    updates_collections=None,
    name=None
)

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

用于计算predictions上不同的thresholds的各种recall值.

该recall_at_thresholds函数为各种阈值创建了四个局部变量:true_positives,true_negatives,false_positives和false_negatives值.recall[i]被定义为大于thresholds[i]的predictions的值的总权重,其中它在labels的相应的条目是True,除以labels中的True值的总权重,即:(true_positives[i] / (true_positives[i] + false_negatives[i]))

为了估计数据流上的度量,该函数创建一个update_op操作来更新这些变量并返回recall.

如果weights是None,则权重默认为1,使用权重0来屏蔽值.

参数:

  • labels:正确标记(ground truth),Tensor的维度必须匹配predictions,将被转换为bool.
  • predictions:任意形状的浮点Tensor,其值在该[0, 1]范围内.
  • thresholds:一个python列表或[0, 1]中浮动阈值的元组.
  • weights:可选的Tensor,其秩为0或与labels具有相同等级,并且必须可广播到labels(即,所有维度必须为1或者与相应的labels维度相同).
  • metrics_collections:recall应添加到的集合的可选列表.
  • updates_collections:update_op应添加到的集合的可选列表.
  • name:可选的variable_scope名称.

返回:

  • recall:一个具有形状[len(thresholds)]的浮动Tensor.
  • update_op:表示递增true_positives,true_negatives,false_positives和false_negatives变量的操作,在计算recall中使用.

可能引发的异常:

  • ValueError:如果predictions和labels有不匹配的形状,或者weights不是None,并且它的形状不匹配predictions,或者如果metrics_collections或updates_collections中任意一个不是一个列表或元组.
  • RuntimeError:如果启用了急切执行.
以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号