MCPcopy Index your code
hub / github.com/GPflow/GPflow / plot_2d_kernel_samples

Function plot_2d_kernel_samples

doc/sphinx/notebooks/getting_started/kernels.pct.py:347–362  ·  view source on GitHub ↗
(ax: Axes, kernel: gpflow.kernels.Kernel)

Source from the content-addressed store, hash-verified

345
346# %%
347def plot_2d_kernel_samples(ax: Axes, kernel: gpflow.kernels.Kernel) -> None:
348 n_grid = 30
349 X = np.zeros((0, 2))
350 Y = np.zeros((0, 1))
351 model = gpflow.models.GPR((X, Y), kernel=deepcopy(kernel))
352
353 Xplots = np.linspace(-0.6, 0.6, n_grid)
354 Xplot1, Xplot2 = np.meshgrid(Xplots, Xplots)
355 Xplot = np.stack([Xplot1, Xplot2], axis=-1)
356 Xplot = Xplot.reshape([n_grid ** 2, 2])
357
358 tf.random.set_seed(20220903)
359 fs = model.predict_f_samples(Xplot, num_samples=1)
360 fs = fs.numpy().reshape((n_grid, n_grid))
361 ax.plot_surface(Xplot1, Xplot2, fs, cmap=coolwarm)
362 ax.set_title("Example $f$")
363
364
365def plot_2d_kernel_prediction(ax: Axes, kernel: gpflow.kernels.Kernel) -> None:

Callers 1

plot_2d_kernelFunction · 0.85

Calls 2

deepcopyFunction · 0.85
predict_f_samplesMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…