Hi all. I’m trying to predict on new data, but pm.sample_posterior_predicitve does not catch the new shape of data. I have tried an approach combining this and this posts, but to no avail. Here’s my latest attempt:

```
import numpy as np
import pymc as pm
rng = np.random.default_rng(18)
score = np.random.normal(0,1, (2,50)).flatten()
fi = np.array([np.arange(50),np.arange(50)]).flatten() #dates index
oi = np.array([np.zeros(50),np.ones(50)]).flatten() #number of options
#### Original model ####
def gen_mod(sco):
with pm.Model() as mod:
zs = pm.MutableData("zs", sco, dims="obs_id")
F = int(zs.get_value().shape[0]/2)
f = np.array([np.arange(F),np.arange(F)]).flatten() #dates index
o = np.array([np.zeros(F).astype("int32"),np.ones(F).astype("int32")]).flatten() #number of options
sd = pm.HalfNormal.dist(1.0)
L, corr, std = pm.LKJCholeskyCov("L", n=2, eta=2.0, sd_dist=sd, compute_corr=True)
Σ = pm.Deterministic("Σ", L.dot(L.T))
w = pm.GaussianRandomWalk("w", shape=(F,2), init_dist=pm.Normal.dist(0,1))
B = pm.Deterministic("B", pm.math.matrix_dot(Σ,w.T))
α = pm.Normal("α", 0, 1.0, shape=F)
μ = pm.Deterministic("μ", α[f] + B[o,f])
ϵ = pm.HalfNormal('ϵ', 1.0)+1
y = pm.Normal("y", mu=μ, sigma=ϵ, observed=zs)
return mod
model = gen_mod(score)
with model:
trace = pm.sample(100, chains=2, cores=12)
#### prediction
s1 = np.concatenate([score[:50], np.ones(20)])
s2 = np.concatenate([score[50:], np.ones(20)])
score_pred = np.array([s1,s2]).flatten()
model_pred = gen_mod(score_pred)
with model_pred:
preds = pm.sample_posterior_predictive(trace)
preds = preds.posterior_predictive
preds = preds['y']
Only 100 samples in chain.
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
Multiprocess sampling (2 chains in 12 jobs)
NUTS: [L, w, α, ϵ]
|████████████| 100.00% [2200/2200 00:53<00:00 Sampling 2 chains, 4 divergences]Sampling 2 chains for 1_000 tune and 100 draw iterations (2_000 + 200 draws total) took 128 seconds.
There were 4 divergences after tuning. Increase `target_accept` or reparameterize.
The acceptance probability does not match the target. It is 0.5258, but should be close to 0.8. Try to increase the number of tuning steps.
|████████████████████| 100.00% [200/200 00:00<00:00]
preds.shape
Out[2]: (2, 100, 100)
score_pred.shape
Out[3]: (140,)
```

So the shape of preds should be (2,100,140). I have tried using multidimensional arrays (i.e. 2 by 50) rather than flattened arrays, but nothing seems to work. Any help would be really appreciated.