Skip to content

Commit f819a4c

Browse files
committed
fix doctest
1 parent fbe3913 commit f819a4c

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

src/layers/recurrent.jl

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,11 @@ julia> Flux.reset!(r);
140140
141141
julia> r(rand(Float32, 3, 10)) |> size # batch size of 10
142142
(5, 10)
143+
```
144+
145+
The following is a demonstration of when failing to call `reset!` between batch size changes can cause erroneous outputs.
143146
144-
# A demonstration of not using `reset!` when the batch size changes.
147+
```julia
145148
julia> r = RNN(3, 5)
146149
Recur(
147150
RNNCell(3, 5, tanh), # 50 parameters
@@ -163,7 +166,7 @@ julia> r(rand(Float32, 3, 10)) |> size # batch size of 10
163166
julia> r.state |> size # state shape has changed
164167
(5, 10)
165168
166-
julia> r(rand(Float32, 3)) |> size # outputs a length 5*10 = 50 vector.
169+
julia> r(rand(Float32, 3)) |> size # erroneously outputs a length 5*10 = 50 vector.
167170
(50,)
168171
```
169172
"""
@@ -246,8 +249,11 @@ julia> Flux.reset!(l);
246249
247250
julia> l(rand(Float32, 3, 10)) |> size # batch size of 10
248251
(5, 10)
252+
```
253+
254+
The following is a demonstration of when failing to call `reset!` between batch size changes can cause erroneous outputs.
249255
250-
# A demonstration of not using `reset!` when the batch size changes.
256+
```julia
251257
julia> l = LSTM(3, 5)
252258
Recur(
253259
LSTMCell(3, 5), # 190 parameters
@@ -266,7 +272,7 @@ julia> l(rand(Float32, 3, 10)) |> size # batch size of 10
266272
julia> l.state .|> size # state shape has changed
267273
((5, 10), (5, 10))
268274
269-
julia> l(rand(Float32, 3)) |> size # outputs a length 5*10 = 50 vector.
275+
julia> l(rand(Float32, 3)) |> size # erroneously outputs a length 5*10 = 50 vector.
270276
(50,)
271277
```
272278
"""
@@ -354,8 +360,11 @@ julia> Flux.reset!(g);
354360
355361
julia> g(rand(Float32, 3, 10)) |> size # batch size of 10
356362
(5, 10)
363+
```
364+
365+
The following is a demonstration of when failing to call `reset!` between batch size changes can cause erroneous outputs.
357366
358-
# A demonstration of not using `reset!` when the batch size changes.
367+
```julia
359368
julia> g = GRU(3, 5)
360369
Recur(
361370
GRUCell(3, 5), # 140 parameters
@@ -374,7 +383,7 @@ julia> g(rand(Float32, 3, 10)) |> size # batch size of 10
374383
julia> g.state |> size # state shape has changed
375384
(5, 10)
376385
377-
julia> g(rand(Float32, 3)) |> size # outputs a length 5*10 = 50 vector.
386+
julia> g(rand(Float32, 3)) |> size # erroneously outputs a length 5*10 = 50 vector.
378387
(50,)
379388
```
380389
"""
@@ -451,8 +460,11 @@ julia> Flux.reset!(g);
451460
452461
julia> g(rand(Float32, 3, 10)) |> size # batch size of 10
453462
(5, 10)
463+
```
464+
465+
The following is a demonstration of when failing to call `reset!` between batch size changes can cause erroneous outputs.
454466
455-
# A demonstration of not using `reset!` when the batch size changes.
467+
```julia
456468
julia> g = GRUv3(3, 5)
457469
Recur(
458470
GRUv3Cell(3, 5), # 140 parameters
@@ -471,7 +483,7 @@ julia> g(rand(Float32, 3, 10)) |> size # batch size of 10
471483
julia> g.state |> size # state shape has changed
472484
(5, 10)
473485
474-
julia> g(rand(Float32, 3)) |> size # outputs a length 5*10 = 50 vector.
486+
julia> g(rand(Float32, 3)) |> size # erroneously outputs a length 5*10 = 50 vector.
475487
(50,)
476488
```
477489
"""

0 commit comments

Comments
 (0)