()
| 27 | |
| 28 | |
| 29 | def 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 | |
| 47 | def test_sgpr_svgp_qu_equivivalent() -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…