1212using ApproximateGPs
1313using Distributions
1414using LinearAlgebra
15+ # jl using DisplayAs
1516
1617using Plots
17- default (; palette= :seaborn_colorblind , legend= :outertopright , size= (700 , 400 ))
18+ default (; fmt = :png , palette= :seaborn_colorblind , legend= :outertopright , size= (700 , 400 ))
1819
1920using Random
2021Random. seed! (1234 );
@@ -29,7 +30,10 @@ N = 10000 # Number of training points
2930x = rand (Uniform (- 1 , 1 ), N)
3031y = g .(x) + 0.3 * randn (N)
3132
32- scatter (x, y; xlabel= " x" , ylabel= " y" , markershape= :xcross , markeralpha= 0.1 , legend= false )
33+ plt = scatter (
34+ x, y; xlabel= " x" , ylabel= " y" , markershape= :xcross , markeralpha= 0.1 , legend= false
35+ )
36+ # jl DisplayAs.PNG(plt)
3337
3438# ## Set up a Flux model
3539#
@@ -145,7 +149,7 @@ model = SVGPModel(k_init, z_init, m_init, A_init);
145149# very poor fit to the data, as expected:
146150
147151init_post = model_posterior (model)
148- scatter (
152+ plt = scatter (
149153 x,
150154 y;
151155 xlabel= " x" ,
@@ -154,7 +158,8 @@ scatter(
154158 markeralpha= 0.1 ,
155159 label= " Training Data" ,
156160)
157- plot! (- 1 : 0.001 : 1 , init_post; label= " Initial Posterior" , color= 4 )
161+ plot! (plt, - 1 : 0.001 : 1 , init_post; label= " Initial Posterior" , color= 4 )
162+ # jl DisplayAs.PNG(plt)
158163
159164# ## Training the model
160165#
@@ -195,7 +200,7 @@ loss(model, x, y)
195200
196201post = model_posterior (model)
197202
198- scatter (
203+ plt = scatter (
199204 x,
200205 y;
201206 markershape= :xcross ,
@@ -207,5 +212,6 @@ scatter(
207212 label= " Training Data" ,
208213 color= 1 ,
209214)
210- plot! (- 1 : 0.001 : 1 , post; label= " Posterior" , color= 4 )
211- sticks! (model. z, fill (0.13 , M); label= " Pseudo-points" , linewidth= 1.5 , color= 5 )
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)
0 commit comments