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

Saving and loading Flux models containing optimizers #329

Closed
rlrs opened this issue Jun 16, 2021 · 4 comments · Fixed by #330
Closed

Saving and loading Flux models containing optimizers #329

rlrs opened this issue Jun 16, 2021 · 4 comments · Fixed by #330

Comments

@rlrs
Copy link

rlrs commented Jun 16, 2021

When saving and loading a model as explained in the Flux docs, I get the error

ERROR: LoadError: MethodError: Cannot convert an object of type Vector{Pair{Any, Any}} to an object of type IdDict.

My model, however, is a bit more involved than a simple Flux Chain. The problem seems to be that it also includes an ADAM optimizer, which has a field called state with the value IdDict{Any,Any}(). I don't understand why this cannot be loaded?

@rlrs rlrs changed the title Saving and loading Flux models containing optimizers. Saving and loading Flux models containing optimizers Jun 16, 2021
@JonasIsensee
Copy link
Collaborator

Hi @rlrs,
can you give me a bit more information, please?
What JLD2 version are you on, which julia version?
Do you have any minimal code that produces the problem?

@rlrs
Copy link
Author

rlrs commented Jun 16, 2021

Sorry for the lack of information. A pretty minimal example is this,

using Flux
using JLD2: @save, @load
opt = ADAM(1)
@save "test.jld2" opt
@load "test.jld2" opt

I'm on Julia 1.6.1, JLD2 v0.4.9, Flux v0.12.4.

JonasIsensee added a commit that referenced this issue Jun 17, 2021
@JonasIsensee
Copy link
Collaborator

Hi,
I implemented a fix in #330.
Does that resolve the problem for you as well?

@rlrs
Copy link
Author

rlrs commented Jun 18, 2021

Thank you, it works in v0.4.10.

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

Successfully merging a pull request may close this issue.

2 participants