How to only compute diagonal of exact posterior distribution #2312
-
After doing exact regression I would like to get the predicted variance at some test points-- only the diagonal of the covariance matrix of the posterior at these points. For this I would do something like this:
But I suspect that |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Nope, you're already doing the right thing! By default in GPyTorch, covariance matrices are evaluated and passed around lazily as |
Beta Was this translation helpful? Give feedback.
Nope, you're already doing the right thing!
By default in GPyTorch, covariance matrices are evaluated and passed around lazily as
LinearOperators
. Thus,pred.lazy_covariance_matrix
is an object that represents the full covariance matrix, but doesn't consume the memory or compute time required to build the whole thing. Callingpred.variance
will only get you the diagonal. It's only if you start asking for e.g. off diagonal elements or functions of the covariance matrix that require the whole thing that we start building covariances.