.Flux
reset!
function
defined in module
Flux
reset!(rnn)
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:
rnn.state = hidden(rnn.cell)
julia> r = Flux.RNNCell(relu, ones(1,1), zeros(1,1), ones(1,1), zeros(1,1)); # users should use the RNN wrapper struct instead
julia> y = Flux.Recur(r, ones(1,1));
julia> y.state
1×1 Matrix{Float64}:
1.0
julia> y(ones(1,1)) # relu(1*1 + 1)
1×1 Matrix{Float64}:
2.0
julia> y.state
1×1 Matrix{Float64}:
2.0
julia> Flux.reset!(y)
1×1 Matrix{Float64}:
0.0
julia> y.state
1×1 Matrix{Float64}:
0.0
There are
2
methods for Flux.reset!
:
The following pages link back here: