Closed vcharvet closed 3 years ago
This can be resolved by using cholesky_jitter
in the last line. This line works for me:
with gpytorch.settings.cholesky_jitter(1e-1):
beta = G.inv_matmul(Y.T[:, :, None],
left_tensor=B.inv_matmul(Kmn.evaluate()))
Numerically, what seems to be happening is that the matrix B
is becoming increasingly ill-conditioned: on your dataset, the smallest eigenvalues from torch.symeig(B.evaluate())
are something like -0.3
.
A more numerically stable implementation exploits G
being a diagonal matrix (the sum of two diagonals):
G = DiagLazyTensor((Knn - Q).diag() + noise.unsqueeze(-1))
B = Kmm + G.inv_matmul(Kmn.transpose(-1, -2).evaluate(),
left_tensor=Kmn.evaluate())
beta = G.inv_matmul(Y.T[:, :, None],
left_tensor=B.inv_matmul(Kmn.evaluate()))
The second fix is probably the one you should use in this setting.
Now, B
surprisingly has only positive eigenvalues. What's happening is that gpytorch doesn't pick up that G
is diagonal (how could it given the sum) and then is running CG after n > 800.
Hi, thank you very much for your quick reply. The second fix works well, on example as well as integrated in the RL setting.
🐛 Bug
Hello, I'm using a sparse multitask GP to learn a dynamical model in a reinforcement learning problem. I'm then using the model to compute Moment Matching predictions at uncertain inputs. It works well up to a certain amount of points.
To reproduce
Code snippet to reproduce
It works for
n=800
but not forn=900
Stack trace/error message
Expected Behavior
For low values of n, but if n is too high, matrix
B
becomes singularSystem information
Please complete the following information: GPytorch version: 1.3.1 Pytorch version: 1.7.0
OS:
$lsb_release - a
Distributor ID: Debian Description: Debian GNU/Linux 9.13 (stretch) Release: 9.13 Codename: stretch
Additional context
In the RL context, we should be able to compute the predictions as $n \rightarrow \infty$
Reference for MM prediction: Peter Deisenroth, M. (2010). Efficient Reinforcement Learning using Gaussian Processes, chapter 2.4