codecamp

TensorFlow函数:tf.losses.huber_loss

tf.losses.huber_loss函数

tf.losses.huber_loss(
    labels,
    predictions,
    weights=1.0,
    delta=1.0,
    scope=None,
    loss_collection=tf.GraphKeys.LOSSES,
    reduction=Reduction.SUM_BY_NONZERO_WEIGHTS
)

定义在:tensorflow/python/ops/losses/losses_impl.py.

将Huber Loss术语添加到训练过程中.

对于error=labels-predictions中的每个x值,计算以下值:

0.5 * x^2                  if |x| <= d
0.5 * d^2 + d * (|x| - d)  if |x| > d      

其中d是delta.

请参阅:https://en.wikipedia.org/wiki/Huber_loss

weights作为loss的系数.如果提供了标量,那么loss只是按给定值进行缩放.如果weights是一个大小为[batch_size]的张量,那么批次的每个样本的总loss由weights向量中的相应元素重新调整.如果weights的形状与predictions形状匹配,则predictions的每个可测量元素的loss由相应的weights值缩放.

参数:

  • labels:真实的输出张量,与“predictions”相同.
  • predictions:预测的输出.
  • weights:可选的Tensor,其秩为0或与labels具有相同的秩,并且必须可广播到labels(即,所有维度必须为1,或者与相应的losses维度相同).
  • delta:float,huber loss函数从二次函数变为线性函数的点.
  • scope:计算loss时执行的操作范围.
  • loss_collection:将添加loss的集合.
  • reduction:适用于loss的减少类型.

返回:

加权损失浮动Tensor,如果reduction是NONE,则它的形状与labels相同,否则,它是标量.

可能引发的异常:

  • ValueError:如果形状predictions的形状与labels不匹配,或weights的形状是无效的;或者如果labels或predictions为None,则会发生此异常.
TensorFlow函数:tf.losses.hinge_loss
TensorFlow函数:tf.losses.log_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; }