numpy - 有没有像张量流中那样的cumulative_logsumexp 的numpy 模拟?
问题描述
我想知道https://www.tensorflow.org/api_docs/python/tf/math/cumulative_logsumexp这个函数在 tensorflow 中是否有一个 numpy 模拟?
解决方案
np.logaddexp.accumulate
. 例如:
>>> np.logaddexp.accumulate(np.arange(7))
array([0. , 1.31326169, 2.40760596, 3.4401897 , 4.4519144 ,
5.45619332, 6.45776285])
# verify:
>>> np.exp(_)
array([ 1. , 3.71828183, 11.10733793, 31.19287485,
85.79102488, 234.20418399, 637.63297748])
>>> np.diff(_)
array([ 2.71828183, 7.3890561 , 20.08553692, 54.59815003,
148.4131591 , 403.42879349])
>>> np.log(_)
array([1., 2., 3., 4., 5., 6.])
推荐阅读
- c# - 图是循环搜索
- python - 将字典数组的前 2 个元素转换为元组
- java - 获取认证密钥,小米手环 5
- c++ - 创建单个掩码以检查位是否已设置、取消设置或接受
- android - 更改 MaterialButtonToggleGroup 的背景颜色
- reactjs - 是的验证,一个字符串上有 2 个正则表达式
- snowflake-cloud-data-platform - Snowflake:数据加载文件大小建议
- docker - 无法通过达到拉取率限制来验证是否安装了 docker 引擎
- pyspark - 如何将处理后的火花流插入卡夫卡
- docker - Docker如何清除只读文件,以便我可以直接从我的计算机而不是容器中更改它?