codecamp

TensorFlow函数:tf.losses.absolute_difference

tf.losses.absolute_difference函数

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

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

在训练过程中添加绝对差值loss.

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

参数:

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

返回:

该函数返回加权loss浮动Tensor.如果reduction是NONE,则它的形状与labels相同;否则,它是标量.

可能引发的异常:

  • ValueError:如果predictions的形状与labels不匹配,或者weights的形状是无效的,或者labels、predictions是None.
TensorFlow模块:tf.losses
TensorFlow函数:tf.losses.add_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; }