1212using ApproximateGPs
1313using Distributions
1414using LinearAlgebra
15- # jl using DisplayAs
1615
1716using Plots
17+ # # We output plots as PNG to reduce their size
1818default (; fmt= :png , palette= :seaborn_colorblind , legend= :outertopright , size= (700 , 400 ))
19+ # nb ## Regardless of the `fmt` setting, by default Literate saves also the SVG output
20+ # nb ## in notebooks: https://github.com/fredrikekre/Literate.jl/issues/61
21+ # nb ## We use DisplayAs to ensure that only the PNG output is saved.
22+ # nb using DisplayAs
1923
2024using Random
2125Random. seed! (1234 );
@@ -30,10 +34,8 @@ N = 10000 # Number of training points
3034x = rand (Uniform (- 1 , 1 ), N)
3135y = g .(x) + 0.3 * randn (N)
3236
33- plt = scatter (
34- x, y; xlabel= " x" , ylabel= " y" , markershape= :xcross , markeralpha= 0.1 , legend= false
35- )
36- # jl DisplayAs.PNG(plt)
37+ scatter (x, y; xlabel= " x" , ylabel= " y" , markershape= :xcross , markeralpha= 0.1 , legend= false )
38+ # nb DisplayAs.PNG(current())
3739
3840# ## Set up a Flux model
3941#
@@ -149,7 +151,7 @@ model = SVGPModel(k_init, z_init, m_init, A_init);
149151# very poor fit to the data, as expected:
150152
151153init_post = model_posterior (model)
152- plt = scatter (
154+ scatter (
153155 x,
154156 y;
155157 xlabel= " x" ,
@@ -158,8 +160,8 @@ plt = scatter(
158160 markeralpha= 0.1 ,
159161 label= " Training Data" ,
160162)
161- plot! (plt, - 1 : 0.001 : 1 , init_post; label= " Initial Posterior" , color= 4 )
162- # jl DisplayAs.PNG(plt )
163+ plot! (- 1 : 0.001 : 1 , init_post; label= " Initial Posterior" , color= 4 )
164+ # nb DisplayAs.PNG(current() )
163165
164166# ## Training the model
165167#
@@ -200,7 +202,7 @@ loss(model, x, y)
200202
201203post = model_posterior (model)
202204
203- plt = scatter (
205+ scatter (
204206 x,
205207 y;
206208 markershape= :xcross ,
@@ -212,6 +214,6 @@ plt = scatter(
212214 label= " Training Data" ,
213215 color= 1 ,
214216)
215- plot! (plt, - 1 : 0.001 : 1 , post; label= " Posterior" , color= 4 )
216- sticks! (plt, model. z, fill (0.13 , M); label= " Pseudo-points" , linewidth= 1.5 , color= 5 )
217- # jl DisplayAs.PNG(plt )
217+ plot! (- 1 : 0.001 : 1 , post; label= " Posterior" , color= 4 )
218+ sticks! (model. z, fill (0.13 , M); label= " Pseudo-points" , linewidth= 1.5 , color= 5 )
219+ # nb DisplayAs.PNG(current() )
0 commit comments