Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Tensorflow:多项式尝试的结果概率_Python_Python 3.x_Tensorflow_Distribution - Fatal编程技术网

Python Tensorflow:多项式尝试的结果概率

Python Tensorflow:多项式尝试的结果概率,python,python-3.x,tensorflow,distribution,Python,Python 3.x,Tensorflow,Distribution,我在做一个多项式尝试-我有一个概率向量p=[p1,p2,p3]和一个观察结果向量n=[n1,n2,n3] 如何使用TensorFlow发现此类事件的概率?我希望有一个解决方案也适用于矩阵(即,我有一个张量,每行表示概率,一个张量,每行表示结果) 您可以使用: 输出: 0.13888888 您还可以同时使用多个发行版,如下所示: import tensorflow as tf probs = tf.placeholder(tf.float32, [None, 3]) counts = tf.p

我在做一个多项式尝试-我有一个概率向量
p=[p1,p2,p3]
和一个观察结果向量
n=[n1,n2,n3]

如何使用TensorFlow发现此类事件的概率?我希望有一个解决方案也适用于矩阵(即,我有一个张量,每行表示概率,一个张量,每行表示结果)

您可以使用:

输出:

0.13888888
您还可以同时使用多个发行版,如下所示:

import tensorflow as tf

probs = tf.placeholder(tf.float32, [None, 3])
counts = tf.placeholder(tf.float32, [None, 3])
total_counts = tf.reduce_sum(counts, axis=1)
multinomial = tf.distributions.Multinomial(total_counts, probs=probs)
prob_counts = multinomial.prob(counts)
在这种情况下,
probs的每一行将是一个概率分布,每一行
计数
一个分布样本,
prob\u的每个元素计数
每个样本的概率

import tensorflow as tf

probs = tf.placeholder(tf.float32, [None, 3])
counts = tf.placeholder(tf.float32, [None, 3])
total_counts = tf.reduce_sum(counts, axis=1)
multinomial = tf.distributions.Multinomial(total_counts, probs=probs)
prob_counts = multinomial.prob(counts)