codecamp

TensorFlow函数:tf.losses.log_loss

tf.losses.log_loss函数

tf.losses.log_loss(
    labels,
    predictions,
    weights=1.0,
    epsilon=1e-07,
    scope=None,
    loss_collection=tf.GraphKeys.LOSSES,
    reduction=Reduction.SUM_BY_NONZERO_WEIGHTS
)

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

在训练过程中添加Log Loss术语.

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

参数:

  • labels:真实的输出张量,与“predictions”相同.
  • predictions:预测的输出.
  • weights:可选的Tensor,其秩为0或与labels具有相同的秩,并且必须可广播到labels(即,所有维度必须为1,或者与相应的losses维度相同).
  • epsilon:要添加的小增量,以避免占用零的日志.
  • scope:计算loss时执行的操作范围.
  • loss_collection:将添加loss的集合.
  • reduction:适用于loss的减少类型.

返回:

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

可能引发的异常:

  • ValueError:如果predictions的形状与labels不匹配,或weights的形状无效,或者如果labels或predictions为None,则会引发此异常.
TensorFlow函数:tf.losses.huber_loss
TensorFlow函数:tf.losses.mean_pairwise_squared_error
温馨提示
下载编程狮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; }