我想在张量流中混合两个多元分布。例如:
import tensorflow_probability as tfp
import tensorflow as tf
import numpy as np
tfd = tfp.distributions
#mean,var,pi have the same shape(3,4).
mean = tf.convert_to_tensor(np.arange(12.0).reshape(3,4))
var = mean
dist = tfd.Normal(loc=mean,scale=var)
pi = tf.ones_like(mean)
mix = tfd.Mixture(cat = tfd.Categorical(probs=[pi,1-pi]),components=[dist,dist])
但是,它得到了如下错误:
ValueError:尺寸 2 和 3 不兼容
ValueError:形状 (2, 3) 和 (3, 4) 不兼容
我可以在张量流中混合两个多元分布吗?