JuliaIO / JLD.jl

Saving and loading julia variables while preserving native types
MIT License
278 stars 55 forks source link

error with loading the jld file containg the reture value of Optim.optimize #301

Open xianqinglt opened 3 years ago

xianqinglt commented 3 years ago

I am using Julia 1.6.1, JLD v0.12.3, Optim v1.3.0 The reture value of Optim.optimize is saved in the "res.jld" file, while loading this file, I got the following error:

julia> res = JLD.load("res.jld"); error parsing type string Optim.MultivariateOptimizationResults{Optim.LBFGS{Core.Nothing,LineSearches.InitialStatic{Core.Float64},LineSearches.HagerZhang{Core.Float64,Base.RefValue{Core.Bool}},Optim.#17#19},Core.Float64,Core.Array{Base.Complex{Core.Float64},3},Core.Float64,Core.Float64,Core.Array{Optim.OptimizationState{Core.Float64,Optim.LBFGS{Core.Nothing,LineSearches.InitialStatic{Core.Float64},LineSearches.HagerZhang{Core.Float64,Base.RefValue{Core.Bool}},Optim.#17#19}},1},Core.Bool,Core.NamedTuple{(:f_limit_reached, :g_limit_reached, :h_limit_reached, :time_limit, :callback, :f_increased),Core.Tuple{Core.Bool,Core.Bool,Core.Bool,Core.Bool,Core.Bool,Core.Bool}}} Error encountered while load FileIO.File{FileIO.DataFormat{:JLD}, String}("res.jld").

Fatal error: ERROR: syntax: incomplete: premature end of input Stacktrace: [1] top-level scope @ none:1 [2] eval @ .\boot.jl:360 [inlined] [3] eval @ C:\Users\dell.julia\packages\JLD\JHrZe\src\JLD.jl:1 [inlined] [4] _julia_type(s::String) @ JLD C:\Users\dell.julia\packages\JLD\JHrZe\src\JLD.jl:1020 [5] julia_type(s::String) @ JLD C:\Users\dell.julia\packages\JLD\JHrZe\src\JLD.jl:41 [6] jldatatype(parent::JLD.JldFile, dtype::HDF5.Datatype) @ JLD C:\Users\dell.julia\packages\JLD\JHrZe\src\jld_types.jl:695 [7] read(obj::JLD.JldDataset) @ JLD C:\Users\dell.julia\packages\JLD\JHrZe\src\JLD.jl:385 [8] read(parent::JLD.JldFile, name::String) @ JLD C:\Users\dell.julia\packages\JLD\JHrZe\src\JLD.jl:361 [9] #43 @ .\none:0 [inlined] [10] iterate @ .\generator.jl:47 [inlined] [11] collect(itr::Base.Generator{Vector{String}, JLD.var"#43#45"{JLD.JldFile}}) @ Base .\array.jl:678 [12] (::JLD.var"#42#44")(file::JLD.JldFile) @ JLD C:\Users\dell.julia\packages\JLD\JHrZe\src\JLD.jl:1271 [13] jldopen(::JLD.var"#42#44", ::String, ::Vararg{String, N} where N; kws::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) @ JLD C:\Users\dell.julia\packages\JLD\JHrZe\src\JLD.jl:261 [14] jldopen @ C:\Users\dell.julia\packages\JLD\JHrZe\src\JLD.jl:259 [inlined] [15] fileio_load(f::FileIO.File{FileIO.DataFormat{:JLD}, String}) @ JLD C:\Users\dell.julia\packages\JLD\JHrZe\src\JLD.jl:1270 [16] #invokelatest#2 @ .\essentials.jl:708 [inlined] [17] invokelatest @ .\essentials.jl:706 [inlined] [18] action(::Symbol, ::Vector{Union{Base.PkgId, Module}}, ::FileIO.Formatted; options::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) @ FileIO C:\Users\dell.julia\packages\FileIO\40aie\src\loadsave.jl:217 [19] action @ C:\Users\dell.julia\packages\FileIO\40aie\src\loadsave.jl:197 [inlined] [20] action(::Symbol, ::Vector{Union{Base.PkgId, Module}}, ::Symbol, ::String; options::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) @ FileIO C:\Users\dell.julia\packages\FileIO\40aie\src\loadsave.jl:185 [21] action @ C:\Users\dell.julia\packages\FileIO\40aie\src\loadsave.jl:185 [inlined] [22] load(::String; options::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) @ FileIO C:\Users\dell.julia\packages\FileIO\40aie\src\loadsave.jl:113 [23] load(::String) @ FileIO C:\Users\dell.julia\packages\FileIO\40aie\src\loadsave.jl:110 [24] top-level scope @ REPL[4]:1 [25] eval @ .\boot.jl:360 [inlined] [26] eval_user_input(ast::Any, backend::REPL.REPLBackend) @ REPL C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\REPL.jl:139 [27] repl_backend_loop(backend::REPL.REPLBackend) @ REPL C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\REPL.jl:200 [28] start_repl_backend(backend::REPL.REPLBackend, consumer::Any) @ REPL C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\REPL.jl:185 [29] run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool) @ REPL C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\REPL.jl:317 [30] run_repl(repl::REPL.AbstractREPL, consumer::Any) @ REPL C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\REPL.jl:305 [31] (::Base.var"#874#876"{Bool, Bool, Bool})(REPL::Module) @ Base .\client.jl:387 [32] #invokelatest#2 @ .\essentials.jl:708 [inlined] [33] invokelatest @ .\essentials.jl:706 [inlined] [34] run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool) @ Base .\client.jl:372 [35] exec_options(opts::Base.JLOptions) @ Base .\client.jl:302 [36] _start() @ Base .\client.jl:485 Stacktrace: [1] handle_error(e::ErrorException, q::Base.PkgId, bt::Vector{Union{Ptr{Nothing}, Base.InterpreterIP}}) @ FileIO C:\Users\dell.julia\packages\FileIO\40aie\src\error_handling.jl:61 [2] handle_exceptions(exceptions::Vector{Tuple{Any, Union{Base.PkgId, Module}, Vector{T} where T}}, action::String) @ FileIO C:\Users\dell.julia\packages\FileIO\40aie\src\error_handling.jl:56 [3] action(::Symbol, ::Vector{Union{Base.PkgId, Module}}, ::FileIO.Formatted; options::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) @ FileIO C:\Users\dell.julia\packages\FileIO\40aie\src\loadsave.jl:226 [4] action @ C:\Users\dell.julia\packages\FileIO\40aie\src\loadsave.jl:197 [inlined] [5] action(::Symbol, ::Vector{Union{Base.PkgId, Module}}, ::Symbol, ::String; options::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) @ FileIO C:\Users\dell.julia\packages\FileIO\40aie\src\loadsave.jl:185 [6] action @ C:\Users\dell.julia\packages\FileIO\40aie\src\loadsave.jl:185 [inlined] [7] load(::String; options::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) @ FileIO C:\Users\dell.julia\packages\FileIO\40aie\src\loadsave.jl:113 [8] load(::String) @ FileIO C:\Users\dell.julia\packages\FileIO\40aie\src\loadsave.jl:110 [9] top-level scope @ REPL[4]:1

xianqinglt commented 3 years ago

I just tested JLD2. It works for data of Optim.