diff --git a/BLcourse2.3/02_two_dim.py b/BLcourse2.3/02_two_dim.py index f808f8698ae338995aa2cc1a982a816202ebac9a..0ff95c63f58835f8672e775b5abce7894960cf78 100644 --- a/BLcourse2.3/02_two_dim.py +++ b/BLcourse2.3/02_two_dim.py @@ -6,7 +6,7 @@ # extension: .py # format_name: light # format_version: '1.5' -# jupytext_version: 1.16.2 +# jupytext_version: 1.17.1 # kernelspec: # display_name: Python 3 (ipykernel) # language: python @@ -29,11 +29,9 @@ # $\DeclareMathOperator{\diag}{diag}$ # $\DeclareMathOperator{\cov}{cov}$ -# + # ##%matplotlib notebook # %matplotlib widget # ##%matplotlib inline -# - # + from collections import defaultdict @@ -137,10 +135,8 @@ X_pred = data_pred.X # Keep the settings below and explore the notebook till the end first. -# + use_noise = False use_gap = False -# - # # Exercise 2 @@ -160,7 +156,6 @@ use_gap = False ##use_gap = True # - -# + if use_noise: # noisy train data noise_std = 0.2 @@ -172,7 +167,6 @@ else: # noise-free train data noise_std = 0 y_train = data_train.z -# - # + # Cut out part of the train data to create out-of-distribution predictions. @@ -484,8 +478,6 @@ ax.set_zlim((contour_z, zlim[1] + abs(contour_z))) ax.contourf(data_pred.XG, data_pred.YG, y_std, zdir="z", offset=contour_z) # - -# + # When running as script if not is_interactive(): plt.show() -# - diff --git a/BLcourse2.3/03_one_dim_SVI.py b/BLcourse2.3/03_one_dim_SVI.py index 00e5d400d9e3171ab2e2c15091417289f11d1e88..7eb6171efd41c7872df50d31aae3ce71d1215892 100644 --- a/BLcourse2.3/03_one_dim_SVI.py +++ b/BLcourse2.3/03_one_dim_SVI.py @@ -175,13 +175,11 @@ pprint(extract_model_params(model)) print("likelihood params:") pprint(extract_model_params(likelihood)) -# + # Set new start hyper params model.mean_module.constant = 3.0 model.covar_module.base_kernel.lengthscale = 1.0 model.covar_module.outputscale = 1.0 likelihood.noise_covar.noise = 0.3 -# - # # Fit GP to data: optimize hyper params #