python - scipy logsumexp() 是否处理下溢挑战?

标签 python arrays numpy scipy natural-logarithm

scipy 的 logsumexp() 实现是否包括通过从每个元素中减去数组中找到的最大值来防止下溢的 hack?

下面解释的那个,其中 m = maxval:

enter image description here

最佳答案

您可以检查定义logsumexp 的源代码here . (请注意,the doc page 上有源链接)。

你会看到:

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

是的,scipy 的 logsumexp 是从每个元素中减去最大值。

关于python - scipy logsumexp() 是否处理下溢挑战?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25651480/

相关文章:

python - '接口(interface)错误 : 2003' when connecting to database

python - 使用 Groupby 对行进行分组并转换开始日期时间和结束日期时间列的行的日期和时间

javascript - 获取数组编号的数组

python - 带有 numpy 随机集的奇怪 FFT 图

python - numpy图像,裁剪一侧,用黑色填充另一侧

python - 在keras中使用Conv3d将多个图像输入到同一个CNN

python - 使用 instapy-cli 将视频和照片上传到 Instagram 时出现问题

c++ - glGetTexImage 读取过多纹理格式为 GL_ALPHA 的数据

javascript - 使用对象复制数组的最佳实践

python - 在 Python 中选择一系列列