codecamp

TensorFlow函数:tf.reduce_logsumexp

tf.reduce_logsumexp 函数
reduce_logsumexp(
    input_tensor,
    axis=None,
    keep_dims=False,
    name=None,
    reduction_indices=None
)

定义在:tensorflow/python/ops/math_ops.py.

请参阅指南:数学函数>减少

计算log(sum(exp(exp(张量的各维数的元素))).

按照给定的axis上的维度减少input_tensor.除非keep_dims是true,否则张量的秩在axis上的每一项都减少1.如果keep_dims为 true,则减少的尺寸将保留为1.

如果axis没有条目,则缩小所有维度,并返回具有单个元素的张量.

这个函数在数值上比 log(sum(exp(input)))更稳定.它避免了大量输入的 exp 引起的溢出和小输入日志带来的下溢.

例如:

x = tf.constant([[0., 0., 0.], [0., 0., 0.]])
tf.reduce_logsumexp(x)  # log(6)
tf.reduce_logsumexp(x, 0)  # [log(2), log(2), log(2)]
tf.reduce_logsumexp(x, 1)  # [log(3), log(3)]
tf.reduce_logsumexp(x, 1, keep_dims=True)  # [[log(3)], [log(3)]]
tf.reduce_logsumexp(x, [0, 1])  # log(6)

参数:

  • input_tensor:张量减少.应该有数字类型.
  • axis:要减小的维度.如果为None(默认),则减少所有维度.必须在[-rank(input_tensor), rank(input_tensor))范围内.
  • keep_dims:如果为true,则保留长度为1的减少尺寸.
  • name:操作的名称(可选).
  • reduction_indices:axis的弃用名称.

返回:

减少的张量.

tf.reduce_join函数:添加字符串张量
TensorFlow函数:tf.reduce_max
温馨提示
下载编程狮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; }