How to load a "jld" file at julia 1.0.3?


Hi there,
I have a program which can work normally at julia 0.6.4, however, after I updated from julia 0.6.4 to 1.0.3, something went wrong. When I using “load” function to load a weights file of a Nertural network, it reports:

1┌ Warning: type Knet.KnetJLD not present in workspace; reconstructing
└ @ JLD ~/.julia/packages/JLD/1BoSz/src/jld_types.jl:703
ERROR: LoadError: MethodError: Cannot `convert` an object of type getfield(JLD, Symbol("##Knet.KnetJLD#361")) to an object of type KnetArray{Float32,N} where N
Closest candidates are:
  convert(::Type{KnetArray{T,N} where N}, ::KnetArray{T,N}) where {T, N} at /home/liuxk/.julia/packages/Knet/05UDD/src/karray.jl:142
  convert(::Type{KnetArray{T,N} where N}, ::KnetArray{S,N}) where {T, N, S} at /home/liuxk/.julia/packages/Knet/05UDD/src/karray.jl:144
  convert(::Type{KnetArray{T,N} where N}, ::AbstractArray{S,N}) where {T, N, S} at /home/liuxk/.julia/packages/Knet/05UDD/src/karray.jl:149
 [1] setindex!(::Array{KnetArray{Float32,N} where N,1}, ::getfield(JLD, Symbol("##Knet.KnetJLD#361")), ::Int64) at ./array.jl:769
 [2] read_refs(::JLD.JldDataset, ::Type{KnetArray{Float32,N} where N}, ::Int64, ::Int64, ::Tuple{Int64}) at /home/liuxk/.julia/packages/JLD/1BoSz/src/JLD.jl:475
 [3] read_array(::JLD.JldDataset, ::HDF5.HDF5Datatype, ::Int64, ::Int64, ::Tuple{Int64}) at /home/liuxk/.julia/packages/JLD/1BoSz/src/JLD.jl:409
 [4] read_array(::JLD.JldDataset, ::HDF5.HDF5Datatype, ::Int64, ::Int64) at /home/liuxk/.julia/packages/JLD/1BoSz/src/JLD.jl:408
 [5] read(::JLD.JldDataset) at /home/liuxk/.julia/packages/JLD/1BoSz/src/JLD.jl:372
 [6] read(::JLD.JldFile, ::String) at /home/liuxk/.julia/packages/JLD/1BoSz/src/JLD.jl:346
 [7] #42 at /home/liuxk/.julia/packages/JLD/1BoSz/src/JLD.jl:1240 [inlined]
 [8] #jldopen#14(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::getfield(JLD, Symbol("##42#43")){String}, ::String, ::Vararg{String,N} where N) at /home/liuxk/.julia/packages/JLD/1BoSz/src/JLD.jl:246
 [9] jldopen at /home/liuxk/.julia/packages/JLD/1BoSz/src/JLD.jl:244 [inlined]
 [10] load at /home/liuxk/.julia/packages/JLD/1BoSz/src/JLD.jl:1239 [inlined]
 [11] #load#13(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::String, ::String) at /home/liuxk/.julia/packages/FileIO/YJO7Z/src/loadsave.jl:118
 [12] load(::String, ::String) at /home/liuxk/.julia/packages/FileIO/YJO7Z/src/loadsave.jl:118
 [13] top-level scope at /home/liuxk/julia-9d11f62bcb/bin/get_prob_score.jl:91
 [14] include at ./boot.jl:317 [inlined]
 [15] include_relative(::Module, ::String) at ./loading.jl:1044
 [16] include(::Module, ::String) at ./sysimg.jl:29
 [17] include(::String) at ./client.jl:392
 [18] top-level scope at none:0
in expression starting at /home/liuxk/julia-9d11f62bcb/bin/get_prob_score.jl:88

Then I realized maybe I need to install JLD2, but it reported the same error. What should I do? Thanks a lot!


Please post quoted code:


There are a number of issues I’ve seen with JLD and JLD2 and I’m not well placed to comment on them, but two general points:

  1. Try to post a minimum working example of your code rather than a screenshot, which makes it possible for others to reproduce your problem (appreciate this can be tricky for JLD issues!)

  2. When updating your code, try going from 0.6 via 0.7 to 1.X - this will give you deprecation warnings rather than errors


Okay, sorry for that again. I will update my post later. Thx!