【发布时间】:2021-02-05 15:50:42
【问题描述】:
我想为事件形状为 n 的 n 个分类变量 C_1、..、C_n 创建一个分布。使用 JointDistributionSequentialAutoBatched 事件维度是一个列表 [[],..,[]]。例如对于 n=2
import tensorflow_probability.python.distributions as tfd
probs = [
[0.8, 0.2], # C_1 in {0,1}
[0.3, 0.3, 0.4] # C_2 in {0,1,2}
]
D = tfd.JointDistributionSequentialAutoBatched([tfd.Categorical(probs=p) for p in probs])
>>> D
<tfp.distributions.JointDistributionSequentialAutoBatched 'JointDistributionSequentialAutoBatched' batch_shape=[] event_shape=[[], []] dtype=[int32, int32]>
如何重塑它以获得事件形状 [2]?
【问题讨论】: