gpt4 book ai didi

python - 如何在tensorflow中计算PDF

转载 作者:太空狗 更新时间:2023-10-30 02:08:40 25 4
gpt4 key购买 nike

在 Matlab 中,我可以使用

计算高斯分布的概率密度函数(PDF)
x = [0.8147,0.9058,0.1270,0.9134,0.6324,0.0975,0.2785,0.5469,0.9575,0.9649]
y = normpdf(x,1.0,2.5)

输出:

y = 0.1591    0.1595    0.1501    0.1595    0.1579    0.1495    0.1531    0.1570    0.1596    0.1596

使用tensorflow,我试过这个

x = tf.variable([0.8147,0.9058,0.1270,0.9134,0.6324,0.0975,0.2785,0.5469,0.9575,0.9649],tf.float32)
y = tf.contrib.distributions.NormalWithSoftplusSigma.pdf(x)

我得到一个错误TypeError: pdf missing 1 required positional argument

如何将 mu 和 sigma 值输入到这个分布中?得到类似的输出。

最佳答案

此函数 pdf 更新为 prob:

dist = tf.contrib.distributions.Normal(1.0, 2.5) 
y = dist.prob(x)

关于python - 如何在tensorflow中计算PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41845802/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com