Skip to content

Commit 074db1b

Browse files
Fix file size of notebook (#103)
* Fix file size of notebook * Fix format Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Change comment Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 8b0002c commit 074db1b

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

examples/a-regression/script.jl

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@
1212
using ApproximateGPs
1313
using Distributions
1414
using LinearAlgebra
15-
#jl using DisplayAs
1615

1716
using Plots
17+
## We output plots as PNG to reduce their size
1818
default(; 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

2024
using Random
2125
Random.seed!(1234);
@@ -30,10 +34,8 @@ N = 10000 # Number of training points
3034
x = rand(Uniform(-1, 1), N)
3135
y = 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

151153
init_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

201203
post = 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

Comments
 (0)