Skip to content

Commit 6a0032b

Browse files
committed
Clean some doctests
1 parent 62870a7 commit 6a0032b

File tree

4 files changed

+12
-43
lines changed

4 files changed

+12
-43
lines changed

docs/src/gpu.md

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,13 @@ Dense(10 => 5) # 55 parameters
6060
julia> x = rand(10) |> gpu
6161
10-element CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}:
6262
0.066846445
63-
0.15663664
64-
0.60529673
65-
0.13574456
66-
0.8381178
67-
0.914712
68-
0.30007496
69-
0.7228498
70-
0.11965257
63+
7164
0.76706964
7265

7366
julia> m(x)
7467
5-element CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}:
7568
-0.99992573
76-
0.08930303
77-
0.4309393
78-
-0.5205649
69+
7970
-0.547261
8071
```
8172

@@ -85,27 +76,13 @@ The analogue `cpu` is also available for moving models and data back off of the
8576
julia> x = rand(10) |> gpu
8677
10-element CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}:
8778
0.8019236
88-
0.03534455
89-
0.48466054
90-
0.8991991
91-
0.9516907
92-
0.8011185
93-
0.12432273
94-
0.114268765
95-
0.07955447
79+
9680
0.7766742
9781

9882
julia> x |> cpu
9983
10-element Vector{Float32}:
10084
0.8019236
101-
0.03534455
102-
0.48466054
103-
0.8991991
104-
0.9516907
105-
0.8011185
106-
0.12432273
107-
0.114268765
108-
0.07955447
85+
10986
0.7766742
11087
```
11188

docs/src/models/overview.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ julia> predict(x_train)
7575
In order to make better predictions, you'll need to provide a *loss function* to tell Flux how to objectively *evaluate* the quality of a prediction. Loss functions compute the cumulative distance between actual values and predictions.
7676

7777
```jldoctest overview
78-
julia> loss(x, y) = Flux.Losses.mse(predict(x), y)
79-
loss (generic function with 1 method)
78+
julia> loss(x, y) = Flux.Losses.mse(predict(x), y);
8079
8180
julia> loss(x_train, y_train)
8281
122.64734f0

docs/src/models/regularisation.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,15 @@ julia> using Flux.Losses: logitcrossentropy
1414
julia> m = Dense(10 => 5)
1515
Dense(10 => 5) # 55 parameters
1616
17-
julia> loss(x, y) = logitcrossentropy(m(x), y)
18-
loss (generic function with 1 method)
17+
julia> loss(x, y) = logitcrossentropy(m(x), y);
1918
```
2019

2120
We can apply L2 regularisation by taking the squared norm of the parameters , `m.weight` and `m.bias`.
2221

2322
```jldoctest regularisation
24-
julia> penalty() = sum(abs2, m.weight) + sum(abs2, m.bias)
25-
penalty (generic function with 1 method)
23+
julia> penalty() = sum(abs2, m.weight) + sum(abs2, m.bias);
2624
27-
julia> loss(x, y) = logitcrossentropy(m(x), y) + penalty()
28-
loss (generic function with 1 method)
25+
julia> loss(x, y) = logitcrossentropy(m(x), y) + penalty();
2926
```
3027

3128
When working with layers, Flux provides the `params` function to grab all
@@ -35,8 +32,7 @@ parameters at once. We can easily penalise everything with `sum`:
3532
julia> Flux.params(m)
3633
Params([Float32[0.34704182 -0.48532376 … -0.06914271 -0.38398427; 0.5201164 -0.033709668 … -0.36169025 -0.5552353; … ; 0.46534058 0.17114447 … -0.4809643 0.04993277; -0.47049698 -0.6206029 … -0.3092334 -0.47857067], Float32[0.0, 0.0, 0.0, 0.0, 0.0]])
3734
38-
julia> sqnorm(x) = sum(abs2, x)
39-
sqnorm (generic function with 1 method)
35+
julia> sqnorm(x) = sum(abs2, x);
4036
4137
julia> sum(sqnorm, Flux.params(m))
4238
8.34994f0
@@ -52,11 +48,9 @@ Chain(
5248
Dense(32 => 10), # 330 parameters
5349
) # Total: 6 arrays, 104_938 parameters, 410.289 KiB.
5450
55-
julia> sqnorm(x) = sum(abs2, x)
56-
sqnorm (generic function with 1 method)
51+
julia> sqnorm(x) = sum(abs2, x);
5752
58-
julia> loss(x, y) = logitcrossentropy(m(x), y) + sum(sqnorm, Flux.params(m))
59-
loss (generic function with 1 method)
53+
julia> loss(x, y) = logitcrossentropy(m(x), y) + sum(sqnorm, Flux.params(m));
6054
6155
julia> loss(rand(28^2), rand(10))
6256
300.76693683244997

docs/src/saving.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ Chain(
107107
julia> evalcb = throttle(30) do
108108
# Show loss
109109
@save "model-checkpoint.bson" model
110-
end
111-
(::Flux.var"#throttled#109"{Flux.var"#throttled#105#110"{Bool, Bool, var"#1#2", Int64}}) (generic function with 1 method)
110+
end;
112111
```
113112

114113
This will update the `"model-checkpoint.bson"` file every thirty seconds.

0 commit comments

Comments
 (0)