MCPcopy
hub / github.com/GPflow/GPflow / compute_qu

Method compute_qu

gpflow/models/sgpr.py:346–377  ·  view source on GitHub ↗

Computes the mean and variance of q(u) = N(mu, cov), the variational distribution on inducing outputs. SVGP with this q(u) should predict identically to SGPR. :return: mu, cov

(self)

Source from the content-addressed store, hash-verified

344 "return[1]: [M, M]",
345 )
346 def compute_qu(self) -> Tuple[tf.Tensor, tf.Tensor]:
347 """
348 Computes the mean and variance of q(u) = N(mu, cov), the variational distribution on
349 inducing outputs.
350
351 SVGP with this q(u) should predict identically to SGPR.
352
353 :return: mu, cov
354 """
355 X_data, Y_data = self.data
356
357 kuf = Kuf(self.inducing_variable, self.kernel, X_data)
358 kuu = Kuu(self.inducing_variable, self.kernel, jitter=default_jitter())
359
360 var = tf.squeeze(self.likelihood.variance_at(X_data), axis=-1)
361 std = tf.sqrt(var)
362 scaled_kuf = kuf / std
363 sig = kuu + tf.matmul(scaled_kuf, scaled_kuf, transpose_b=True)
364 sig_sqrt = tf.linalg.cholesky(sig)
365
366 sig_sqrt_kuu = tf.linalg.triangular_solve(sig_sqrt, kuu)
367
368 cov = tf.linalg.matmul(sig_sqrt_kuu, sig_sqrt_kuu, transpose_a=True)
369 err = Y_data - self.mean_function(X_data)
370 scaled_err = err / std[..., None]
371 mu = tf.linalg.matmul(
372 sig_sqrt_kuu,
373 tf.linalg.triangular_solve(sig_sqrt, tf.linalg.matmul(scaled_kuf, scaled_err)),
374 transpose_a=True,
375 )
376
377 return mu, cov
378
379
380class GPRFITC(SGPRBase_deprecated):

Callers 2

test_sgpr_quFunction · 0.80

Calls 4

KufFunction · 0.85
KuuFunction · 0.85
default_jitterFunction · 0.85
variance_atMethod · 0.80

Tested by 2

test_sgpr_quFunction · 0.64