codecamp

TensorFlow函数:tf.losses.mean_pairwise_squared_error

tf.losses.mean_pairwise_squared_error函数

tf.losses.mean_pairwise_squared_error(
    labels,
    predictions,
    weights=1.0,
    scope=None,
    loss_collection=tf.GraphKeys.LOSSES
)

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

在训练过程中添加一对误差平方loss.

与mean_squared_error不同的是,这是predictions和labels的对应元素之间的差异的量度,mean_pairwise_squared_error是predictions和labels对应元素对之间的差异的量度.

例如,如果labels= [a,b,c]和predictions= [x,y,z],则将三对差值相加以计算loss:loss = [ ((a-b) - (x-y)).^2 + ((a-c) - (x-z)).^2 + ((b-c) - (y-z)).^2 ] / 3

请注意,由于输入具有形状[batch_size, d0, ... dN],因此在每个批处理示例中计算相应的对,但不在批次内的样本之间计算.例如,如果predictions表示一批16个维度为[batch_size,100,200]的灰度图像,则会从每个图像中提取一对配对集,而不是跨图像绘制.

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

参数:

  • labels:真实的输出张量,其形状必须与predictions的形状相匹配.
  • predictions:预测输出,一个大小为[batch_size, d0, .. dN]的张量,其中N+1是predictions中维度的总数.
  • weights:loss的系数,是标量,形状为[batch_size]的张量或与predictions的形状匹配的张量.
  • scope:计算loss时执行的操作范围.
  • loss_collection:将添加loss的集合.

返回:

返回加权损失的标量Tensor.

可能引发的异常:

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