Slight modifications in `recurrent` docstrings
This commit is contained in:
parent
3b913cd501
commit
aaa0a82b74
|
@ -15,13 +15,13 @@ in the background. `cell` should be a model of the form:
|
||||||
For example, here's a recurrent network that keeps a running total of its inputs:
|
For example, here's a recurrent network that keeps a running total of its inputs:
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
accum(h, x) = (h+x, x)
|
accum(h, x) = (h + x, x)
|
||||||
rnn = Flux.Recur(accum, 0)
|
rnn = Flux.Recur(accum, 0)
|
||||||
rnn(2) # 2
|
rnn(2) # 2
|
||||||
rnn(3) # 3
|
rnn(3) # 3
|
||||||
rnn.state # 5
|
rnn.state # 5
|
||||||
rnn.(1:10) # apply to a sequence
|
rnn.(1:10) # apply to a sequence
|
||||||
rnn.state # 60
|
rnn.state # 60
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
mutable struct Recur{T}
|
mutable struct Recur{T}
|
||||||
|
@ -47,9 +47,10 @@ Base.show(io::IO, m::Recur) = print(io, "Recur(", m.cell, ")")
|
||||||
|
|
||||||
Reset the hidden state of a recurrent layer back to its original value.
|
Reset the hidden state of a recurrent layer back to its original value.
|
||||||
|
|
||||||
Assuming you have a `Recur` layer `rnn`, this is roughly equivalent to
|
Assuming you have a `Recur` layer `rnn`, this is roughly equivalent to:
|
||||||
|
```
|
||||||
rnn.state = hidden(rnn.cell)
|
rnn.state = hidden(rnn.cell)
|
||||||
|
```
|
||||||
"""
|
"""
|
||||||
reset!(m::Recur) = (m.state = m.init)
|
reset!(m::Recur) = (m.state = m.init)
|
||||||
reset!(m) = foreach(reset!, functor(m)[1])
|
reset!(m) = foreach(reset!, functor(m)[1])
|
||||||
|
|
Loading…
Reference in New Issue