MCPcopy
hub / github.com/GPflow/GPflow / test_sgpr_qu

Function test_sgpr_qu

tests/gpflow/models/test_sgpr.py:29–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27
28
29def test_sgpr_qu() -> None:
30 rng = np.random.RandomState(1)
31 X = to_default_float(Datum.X)
32 Z = to_default_float(Datum.Z)
33 Y = to_default_float(np.sin(X @ np.array([[-1.4], [0.5]])) + 0.5 * rng.randn(len(X), 1))
34 model = gpflow.models.SGPR(
35 (X, Y), kernel=gpflow.kernels.SquaredExponential(), inducing_variable=Z
36 )
37
38 gpflow.optimizers.Scipy().minimize(model.training_loss, variables=model.trainable_variables)
39
40 qu_mean, qu_cov = model.compute_qu()
41 f_at_Z_mean, f_at_Z_cov = model.predict_f(model.inducing_variable.Z, full_cov=True)
42
43 np.testing.assert_allclose(qu_mean, f_at_Z_mean, rtol=1e-5, atol=1e-5)
44 np.testing.assert_allclose(tf.reshape(qu_cov, (1, 20, 20)), f_at_Z_cov, rtol=1e-5, atol=1e-5)
45
46
47def test_sgpr_svgp_qu_equivivalent() -> None:

Callers

nothing calls this directly

Calls 4

to_default_floatFunction · 0.90
compute_quMethod · 0.80
minimizeMethod · 0.45
predict_fMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…