Dirichlet-Multinomial 复合分布。
继承自:Distribution
用法
tf.compat.v1.distributions.DirichletMultinomial(
total_count, concentration, validate_args=False, allow_nan_stats=True,
name='DirichletMultinomial'
)参数
-
total_count非负浮点张量,其 dtype 与concentration相同。该形状可通过m >= 0广播到[N1,..., Nm]。将此定义为一批N1 x ... x Nm不同的狄利克雷多项分布。它的组件应该等于整数值。 -
concentration正浮点张量,其 dtype 与n相同,形状可广播到[N1,..., Nm, K]m >= 0。将此定义为一批N1 x ... x Nm不同的K类狄利克雷多项分布。 -
validate_argsPythonbool,默认False。尽管可能会降低运行时性能,但检查True分发参数的有效性时。当False无效输入可能会默默呈现不正确的输出。 -
allow_nan_statsPythonbool,默认True。当True时,统计信息(例如,均值、众数、方差)使用值“NaN”来指示结果未定义。当False时,如果一个或多个统计数据的批处理成员未定义,则会引发异常。 -
namePythonstr名称以此类创建的 Ops 为前缀。
属性
-
allow_nan_statsPythonbool说明未定义统计信息时的行为。统计数据在有意义时返回 +/- 无穷大。例如,柯西分布的方差是无穷大的。但是,有时统计数据是未定义的,例如,如果分布的 pdf 在分布的支持范围内没有达到最大值,则模式是未定义的。如果均值未定义,则根据定义,方差未定义。例如: df = 1 的 Student's T 的平均值是未定义的(没有明确的方式说它是 + 或 - 无穷大),因此方差 = E[(X - mean)**2] 也是未定义的。
-
batch_shape来自单个事件索引的单个样本的形状作为TensorShape.可能部分定义或未知。
批次维度是该分布的独立、不同参数化的索引。
-
concentration浓度参数;该坐标的预期先前计数。 -
dtypeTensor的DType由此Distribution处理。 -
event_shape单个批次的单个样品的形状作为TensorShape.可能部分定义或未知。
-
name此Distribution创建的所有操作前的名称。 -
parameters用于实例化此Distribution的参数字典。 -
reparameterization_type说明如何重新参数化分布中的样本。目前这是静态实例
distributions.FULLY_REPARAMETERIZED或distributions.NOT_REPARAMETERIZED之一。 -
total_concentrationlast dim of 浓度参数的总和。 -
total_count用于构建样本的试验次数。 -
validate_argsPythonbool表示启用了可能昂贵的检查。
Dirichlet-Multinomial 分布由(一批)长度参数化 - K concentration 向量( K > 1 )和 total_count 试验次数,即从 DirichletMultinomial 中每次抽取的试验次数。它是在(一批)长度上定义的 - K 向量 counts 使得 tf.reduce_sum(counts, -1) = total_count 。 Dirichlet-Multinomial 与 K = 2 时的 Beta-Binomial 分布相同。
数学细节
Dirichlet-Multinomial 是在 K -类计数上的分布,即非负整数 counts = n = [n_0, ..., n_{K-1}] 的长度 - K 向量。
概率质量函数 (pmf) 是,
pmf(n; alpha, N) = Beta(alpha + n) / (prod_j n_j!) / Z
Z = Beta(alpha) / N!
其中:
concentration = alpha = [alpha_0, ..., alpha_{K-1}],alpha_j > 0,total_count = N,N一个正整数,N!是N阶乘,并且,Beta(x) = prod_j Gamma(x_j) / Gamma(sum_j x_j)是多元 beta 函数,并且,Gamma是伽玛函数。
Dirichlet-Multinomial 是一个复合分布,即它的样本生成如下。
- 选择类概率:
probs = [p_0,...,p_{K-1}] ~ Dir(concentration) - 绘制整数:
counts = [n_0,...,n_{K-1}] ~ Multinomial(total_count, probs)
最后一个 concentration 维度参数化了单个 Dirichlet-Multinomial 分布。当调用分布函数(例如 dist.prob(counts) )时,concentration , total_count 和 counts 被广播到相同的形状。 counts 的最后一个维度对应于单个 Dirichlet-Multinomial 分布。
分布参数在所有函数中自动广播;有关详细信息,请参见示例。
陷阱
类数 K 不得超过:
self.dtype可表示的最大整数,即2**(mantissa_bits+1)(IEE754),- 最大
Tensor索引,即2**31-1。
换一种说法,
K <= min(2**31-1, {
tf.float16:2**11,
tf.float32:2**24,
tf.float64:2**53 }[param.dtype])注意:此条件仅在 self.validate_args = True 时有效。
例子
alpha = [1., 2., 3.]
n = 2.
dist = DirichletMultinomial(n, alpha)
创建一个 3 类分布,最有可能绘制 3 类分布。分布函数可以根据计数进行评估。
# counts same shape as alpha.
counts = [0., 0., 2.]
dist.prob(counts) # Shape []
# alpha will be broadcast to [[1., 2., 3.], [1., 2., 3.]] to match counts.
counts = [[1., 1., 0.], [1., 0., 1.]]
dist.prob(counts) # Shape [2]
# alpha will be broadcast to shape [5, 7, 3] to match counts.
counts = [[...]] # Shape [5, 7, 3]
dist.prob(counts) # Shape [5, 7]
创建 2 批 3 类分布。
alpha = [[1., 2., 3.], [4., 5., 6.]] # Shape [2, 3]
n = [3., 3.]
dist = DirichletMultinomial(n, alpha)
# counts will be broadcast to [[2., 1., 0.], [2., 1., 0.]] to match alpha.
counts = [2., 1., 0.]
dist.prob(counts) # Shape [2]
相关用法
- Python tf.compat.v1.distributions.DirichletMultinomial.log_survival_function用法及代码示例
- Python tf.compat.v1.distributions.DirichletMultinomial.survival_function用法及代码示例
- Python tf.compat.v1.distributions.DirichletMultinomial.quantile用法及代码示例
- Python tf.compat.v1.distributions.DirichletMultinomial.log_cdf用法及代码示例
- Python tf.compat.v1.distributions.DirichletMultinomial.covariance用法及代码示例
- Python tf.compat.v1.distributions.DirichletMultinomial.cdf用法及代码示例
- Python tf.compat.v1.distributions.DirichletMultinomial.variance用法及代码示例
- Python tf.compat.v1.distributions.DirichletMultinomial.kl_divergence用法及代码示例
- Python tf.compat.v1.distributions.DirichletMultinomial.stddev用法及代码示例
- Python tf.compat.v1.distributions.DirichletMultinomial.cross_entropy用法及代码示例
- Python tf.compat.v1.distributions.Dirichlet.covariance用法及代码示例
- Python tf.compat.v1.distributions.Dirichlet.stddev用法及代码示例
- Python tf.compat.v1.distributions.Dirichlet.kl_divergence用法及代码示例
- Python tf.compat.v1.distributions.Dirichlet.cross_entropy用法及代码示例
- Python tf.compat.v1.distributions.Dirichlet.cdf用法及代码示例
- Python tf.compat.v1.distributions.Dirichlet.survival_function用法及代码示例
- Python tf.compat.v1.distributions.Dirichlet.log_survival_function用法及代码示例
- Python tf.compat.v1.distributions.Dirichlet.log_cdf用法及代码示例
- Python tf.compat.v1.distributions.Dirichlet.variance用法及代码示例
- Python tf.compat.v1.distributions.Dirichlet用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.compat.v1.distributions.DirichletMultinomial。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
