MCPcopy
hub / github.com/GPflow/GPflow / plot_kernel_samples

Function plot_kernel_samples

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

Source from the content-addressed store, hash-verified

95
96# %%
97def plot_kernel_samples(ax: Axes, kernel: gpflow.kernels.Kernel) -> None:
98 X = np.zeros((0, 1))
99 Y = np.zeros((0, 1))
100 model = gpflow.models.GPR((X, Y), kernel=deepcopy(kernel))
101 Xplot = np.linspace(-0.6, 0.6, 100)[:, None]
102 tf.random.set_seed(20220903)
103 n_samples = 3
104 # predict_f_samples draws n_samples examples of the function f, and returns their values at Xplot.
105 fs = model.predict_f_samples(Xplot, n_samples)
106 ax.plot(Xplot, fs[:, :, 0].numpy().T, label=kernel.__class__.__name__)
107 ax.set_ylim(bottom=-2.0, top=2.0)
108 ax.set_title("Example $f$s")
109
110
111def plot_kernel_prediction(

Callers 1

plot_kernelFunction · 0.85

Calls 3

deepcopyFunction · 0.85
predict_f_samplesMethod · 0.80
plotMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…