Error running model-zoo example cifar10.jl of the Flux package

flux

#1

I tried with ]instantiate first, and without, same result. Seems to be a problem with conversion to Float32 of Forward.Diff.Dual. Not sure how to go about it, any help would be appreciated.

julia> include("cifar10.jl")
ERROR: LoadError: MethodError: no method matching Float32(::ForwardDiff.Dual{Nothing,Float64,1})
Closest candidates are:
  Float32(::Real, ::RoundingMode) where T<:AbstractFloat at rounding.jl:185
  Float32(::T<:Number) where T<:Number at boot.jl:725
  Float32(::Int8) at float.jl:60
  ...
in expression starting at /Users/aamzallag/code_programming/julia/model-zoo/vision/cifar10/cifar10.jl:122

#2

Maybe fixed by https://github.com/FluxML/Flux.jl/commit/152ce4a164a4602bf8804090e79b1ca59772f70c.

Try use Flux master?


#3

Thank you! I am trying that (cifar10.jl takes a few minutes to run).

Quick question: I did ]add Flux#master (activated project is cifar10). Is it the right way to do it? Does it modifies the Manifest.toml so that it will always use this git commit?


#4

Unfortunately that did not work:

(cifar10) pkg> add Flux#master
   Cloning git-repo `https://github.com/FluxML/Flux.jl.git`
  Updating git-repo `https://github.com/FluxML/Flux.jl.git`
 Resolving package versions...
  Updating `~/code_programming/julia/model-zoo/vision/cifar10/Project.toml`
  [587475ba] ↑ Flux v0.7.1 ⇒ v0.7.1+ #master (https://github.com/FluxML/Flux.jl.git)
  Updating `~/code_programming/julia/model-zoo/vision/cifar10/Manifest.toml`
  [587475ba] ↑ Flux v0.7.1 ⇒ v0.7.1+ #master (https://github.com/FluxML/Flux.jl.git)

julia> include("cifar10.jl")
ERROR: LoadError: MethodError: no method matching Float32(::ForwardDiff.Dual{Nothing,Float64,1})
Closest candidates are:
  Float32(::Real, ::RoundingMode) where T<:AbstractFloat at rounding.jl:185
  Float32(::T<:Number) where T<:Number at boot.jl:725
  Float32(::Int8) at float.jl:60
  ...
in expression starting at /Users/aamzallag/code_programming/julia/model-zoo/vision/cifar10/cifar10.jl:122

line 122 where is fails is:

Flux.train!(loss, params(m), train, opt, cb = evalcb)

I don’t know how to go from there, to find where in the function calls the error happens…