codecamp

TensorFlow函数:tf.losses.cosine_distance

tf.losses.cosine_distance函数

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

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

在训练过程中增加了余弦距离loss.(已否决的参数)

某些参数已弃用.它们将在未来版本中删除.更新说明:不推荐使用dim,而是使用axis

请注意,该函数假定predictions和labels已经进行了单元规范化.

参数:

  • labels:形状与“predictions”匹配的Tensor
  • predictions:任意矩阵.
  • axis:计算余弦距离的维数.
  • weights:可选,秩为0或与labels具有相同秩的Tensor,并且必须可广播到labels(即,所有维度必须为1,或者与相应的losses的维度相同).
  • scope:计算loss时执行的操作范围.
  • loss_collection:将添加此loss的集合.
  • reduction:适用于loss的减少类型.
  • dim:axis的旧的(已弃用)名称.

返回:

加权损耗浮动张量.如果还原为 NONE, 则与标签的形状相同;否则, 它是标量.


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

可能引发的异常:

  • ValueError:如果predictions的形状与labels的形状不匹配,或者axis,labels,predictions、weights是None.
TensorFlow函数:tf.losses.compute_weighted_loss
TensorFlow函数:tf.losses.get_losses
温馨提示
下载编程狮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; }