Ok, I was able to use the tile function to get the model to build and sample, see below:
with pm.Model() as model:
coefficient_vector = dfn.assemble_coefficient_vector(feature_shapes, fit_intercept=fit_intercept)
mu = theano.sparse.dot(X, coefficient_vector)
kappa = pm.HalfNormal('κ', sd=1.0, shape=(1, 1))
w = pm.Beta('w', alpha=1, beta=1)
degenerate_mu = theano.tensor.as_tensor_variable(DEGENERATE_VALUE)
degenerate_mu = theano.tensor.tile(degenerate_mu, reps=[M, 1])
degenerate_sd = theano.tensor.as_tensor_variable(np.array([[1e-5]]))
pm.NormalMixture('likelihood', w=[w, 1 - w],
mu=theano.tensor.stack([mu, degenerate_mu]),
sd=theano.tensor.stack([kappa, degenerate_sd]),
observed=success_rate)
Unfortunately, it’s quite slow and I think part of the reason is that mu is a 2 x M vector with M > 6000, but I’m not sure how to refactor this to use in a regression scenario.