Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flux.destructure doesn't preserve RNN state #1329

Closed
avik-pal opened this issue Sep 3, 2020 · 1 comment · Fixed by #2500
Closed

Flux.destructure doesn't preserve RNN state #1329

avik-pal opened this issue Sep 3, 2020 · 1 comment · Fixed by #2500
Labels

Comments

@avik-pal
Copy link
Member

avik-pal commented Sep 3, 2020

As pointed out here SciML/DiffEqFlux.jl#391 (comment), when reconstructing Recur, the state values are reverted to the initial state. A simple solution would be to do

mutable struct MyRecur{T}
  cell::T
  init
  state
end

function (m::MyRecur)(xs...)
  h, y = m.cell(m.state, xs...)
  m.state = h
  return y
end

Flux.@functor MyRecur

Flux.trainable(r::MyRecur) = Flux.trainable(r.cell)

EDIT: This doesn't work as expected

@DhairyaLGandhi
Copy link
Member

Worth a PR, although it needs to be compatible with reset as well, so we don't move things off the GPU accidentally. In which case, are the arguments to functor doing anything?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants