返回来自的样本的关联概率tf多项式以十为单位

2024-06-26 02:26:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我用tf.multinomial在Tensorflow中生成样本,我在寻找一种返回随机选择元素的关联概率的方法。所以在以下情况下:

logits = [[-1., 0., 1], [1, 1, 1], [0, 1, 2]]
samples = tf.multinomial(logits, 2)

with tf.Session() as sess:
    sess.run(samples)

而不是

^{pr2}$

因此,我想看看

[[(1, 0.244728), (2, 0.66524)], 
 [(0, 0.33333), (1, 0.33333)], 
 [(1, 0.244728), (1, 0.244728)]]

有没有办法做到这一点?在


Tags: 方法run元素sessiontftensorflowaswith
1条回答
网友
1楼 · 发布于 2024-06-26 02:26:10

我很困惑,张量流是否在内部做了某种转换,将逻辑转化为概率?多项式分布接受一组位置概率作为参数,这些概率决定结果(位置)被抽样的可能性。i、 e

# this is all psuedocode
x = multinomial([.2, .3, .5])
y ~ x
# this will give a value of 0 20% of the time
# a value of 1 30% of the time
# and a value of 2 50% of the time

所以你的概率可能就是你的逻辑。在

看着https://www.tensorflow.org/api_docs/python/tf/multinomial

你可以看到它声明它们是“非标准化的日志概率”,所以如果你能应用这个转换,你就有了概率

相关问题 更多 >