是否SciPy的logsumexp()处理下溢挑战? [英] Does scipy logsumexp() deal with the underflow challenge?

查看:227
本文介绍了是否SciPy的logsumexp()处理下溢挑战?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请问SciPy的的 logsumexp()实施包括由每一个元素?

Does the scipy's logsumexp() implementation include the hack that prevents underflow by subtracting the maximum found value in the array from each element?

在一个在这里下面,解释其中 M = MAXVAL

The one explained here below, where m = maxval:

推荐答案

您可以检查源$ C ​​$ C定义 logsumexp 此处。 (请注意,是到源链接上的商务部页)。

You can inspect the source code defining logsumexp here. (Note that there is a link to the source on the doc page).

您将看到:

a_max = a.max(axis=0)
...
out = log(sum(exp(a - a_max), axis=0))

所以,是的,SciPy的的 logsumexp 是减去每个元素的最大值。

So yes, scipy's logsumexp is subtracting the maximum from each element.

这篇关于是否SciPy的logsumexp()处理下溢挑战?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆