I have a model where I end up generating a lot of GPs, so I made a function:
def do_gp(name):
lengthscale = pm.Weibull(f'{name}_lengthscale', alpha=2, beta=1)
cov = pm.gp.cov.ExpQuad(1, ls=lengthscale, active_dims=[0])
gp = pm.gp.Latent(cov_func = cov)
out = gp.prior(f'{name}_gp_samples', X=time[:,None])
return(out)
Used as:
with pm.Model() as model:
time = pm.MutableData('time', time_np)
a_samples = do_gp('a')
b_samples = do_gp('b')
# etc
But now I’d like to use the gp.conditional()
function for each such created gp to obtain posterior predictive samples and I can’t quite discern how to go about doing that when each of the gp
objects were declared inside a function as I’ve done. Any suggestions?