【发布时间】:2017-04-30 22:43:09
【问题描述】:
我想使用 DensityDist 的统一优先级自定义分布中的样本。精神上的东西:
import theano.tensor as T
from pymc3 import DensityDist, Uniform, Model
with Model() as model:
lim = 3
x0 = Uniform('x0', -lim, lim)
x1 = Uniform('x1', -lim, lim)
x = T.concatenate([x0,x1])
# Create custom densities
star = DensityDist('star', lambda x: star(x[:,0],x[:,1]))
其中star 是将二维笛卡尔点映射到非标准化对数似然函数的函数。这是我想使用 Metropolis-Hastings 进行采样的函数。
我尝试了多种变体,但都没有奏效。当前代码失败:
ValueError: The index list is longer (size 2) than the number of dimensions of the tensor(namely 0). You are asking for a dimension of the tensor that does not exist! You might need to use dimshuffle to add extra dimension to your tensor.
任何帮助表示赞赏!
【问题讨论】: