@@ -140,8 +140,11 @@ julia> Flux.reset!(r);
140
140
141
141
julia> r(rand(Float32, 3, 10)) |> size # batch size of 10
142
142
(5, 10)
143
+ ```
144
+
145
+ The following is a demonstration of when failing to call `reset!` between batch size changes can cause erroneous outputs.
143
146
144
- # A demonstration of not using `reset!` when the batch size changes.
147
+ ```julia
145
148
julia> r = RNN(3, 5)
146
149
Recur(
147
150
RNNCell(3, 5, tanh), # 50 parameters
@@ -163,7 +166,7 @@ julia> r(rand(Float32, 3, 10)) |> size # batch size of 10
163
166
julia> r.state |> size # state shape has changed
164
167
(5, 10)
165
168
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.
167
170
(50,)
168
171
```
169
172
"""
@@ -246,8 +249,11 @@ julia> Flux.reset!(l);
246
249
247
250
julia> l(rand(Float32, 3, 10)) |> size # batch size of 10
248
251
(5, 10)
252
+ ```
253
+
254
+ The following is a demonstration of when failing to call `reset!` between batch size changes can cause erroneous outputs.
249
255
250
- # A demonstration of not using `reset!` when the batch size changes.
256
+ ```julia
251
257
julia> l = LSTM(3, 5)
252
258
Recur(
253
259
LSTMCell(3, 5), # 190 parameters
@@ -266,7 +272,7 @@ julia> l(rand(Float32, 3, 10)) |> size # batch size of 10
266
272
julia> l.state .|> size # state shape has changed
267
273
((5, 10), (5, 10))
268
274
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.
270
276
(50,)
271
277
```
272
278
"""
@@ -354,8 +360,11 @@ julia> Flux.reset!(g);
354
360
355
361
julia> g(rand(Float32, 3, 10)) |> size # batch size of 10
356
362
(5, 10)
363
+ ```
364
+
365
+ The following is a demonstration of when failing to call `reset!` between batch size changes can cause erroneous outputs.
357
366
358
- # A demonstration of not using `reset!` when the batch size changes.
367
+ ```julia
359
368
julia> g = GRU(3, 5)
360
369
Recur(
361
370
GRUCell(3, 5), # 140 parameters
@@ -374,7 +383,7 @@ julia> g(rand(Float32, 3, 10)) |> size # batch size of 10
374
383
julia> g.state |> size # state shape has changed
375
384
(5, 10)
376
385
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.
378
387
(50,)
379
388
```
380
389
"""
@@ -451,8 +460,11 @@ julia> Flux.reset!(g);
451
460
452
461
julia> g(rand(Float32, 3, 10)) |> size # batch size of 10
453
462
(5, 10)
463
+ ```
464
+
465
+ The following is a demonstration of when failing to call `reset!` between batch size changes can cause erroneous outputs.
454
466
455
- # A demonstration of not using `reset!` when the batch size changes.
467
+ ```julia
456
468
julia> g = GRUv3(3, 5)
457
469
Recur(
458
470
GRUv3Cell(3, 5), # 140 parameters
@@ -471,7 +483,7 @@ julia> g(rand(Float32, 3, 10)) |> size # batch size of 10
471
483
julia> g.state |> size # state shape has changed
472
484
(5, 10)
473
485
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.
475
487
(50,)
476
488
```
477
489
"""
0 commit comments