After inferring GPRegression with MCMC, regarding the usage of the Predictive class

Hello. I have a question regarding predicting with a Gaussian Processes model that has been inferred using MCMC, based on the GPRegression model example in Pyro.

Gaussian Processes — Pyro documentation

  1. My code is as follows. Could you please confirm if the process of using the Predictive function is correct?
X = torch.tensor([[1, 5, 3], [4, 3, 7]])
y = torch.tensor([2, 1])
kernel = gp.kernels.RBF(input_dim=3)
kernel.set_prior("variance", dist.Exponential(1))
kernel.set_prior("lengthscale", dist.LogNormal(torch.tensor(0.0), torch.tensor(1.0)))
gpr = gp.models.GPRegression(X, y, kernel)

hmc_kernel = HMC(gpr.model)
mcmc = MCMC(hmc_kernel, num_samples=10)

def predictive(X_new):
    h_new_loc, h_new_cov = gpr(X_new)
    pyro.sample("y_mean", dist.Delta(h_new_loc))
    pyro.sample("y_var", dist.Delta(h_new_cov)) 

Xnew = torch.tensor([[1, 5, 3]], dtype=torch.float32)
posterior_predictive = Predictive(predictive, mcmc.get_samples())
y_pred = posterior_predictive.get_samples(Xnew)["y_mean"].detach()
y_pred_var = posterior_predictive.get_samples(Xnew)["y_var"].detach()
  1. During MCMC inference(GPR), Obtaining predicted values like this is incorrect, isn’t it?
Xnew = torch.tensor([[2., 3, 1]])
f_loc, f_cov = gpr(Xnew, full_cov=True)