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

vae_mnist: Mutating arrays is not supported #301

Open
jstrube opened this issue May 8, 2021 · 0 comments
Open

vae_mnist: Mutating arrays is not supported #301

jstrube opened this issue May 8, 2021 · 0 comments

Comments

@jstrube
Copy link
Contributor

jstrube commented May 8, 2021

When running vae_mnist with Flux v0.12.3 causes:

 ERROR: LoadError: Mutating arrays is not supported
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:33
  [2] (::Zygote.var"#411#412")(#unused#::Nothing)
    @ Zygote ~/.julia/packages/Zygote/6HN9x/src/lib/array.jl:65
  [3] (::Zygote.var"#2279#back#413"{Zygote.var"#411#412"})(Δ::Nothing)
    @ Zygote ~/.julia/packages/ZygoteRules/OjfTt/src/adjoint.jl:59
  [4] Pullback
    @ ~/.julia/packages/Flux/6o4DQ/src/functor.jl:45 [inlined]
  [5] (::typeof(∂(params!)))(Δ::Nothing)
    @ Zygote ~/.julia/packages/Zygote/6HN9x/src/compiler/interface2.jl:0
  [6] Pullback
    @ ~/.julia/packages/Flux/6o4DQ/src/functor.jl:47 [inlined]
  [7] (::typeof(∂(params!)))(Δ::Nothing)
    @ Zygote ~/.julia/packages/Zygote/6HN9x/src/compiler/interface2.jl:0
  [8] Pullback
    @ ~/.julia/packages/Flux/6o4DQ/src/functor.jl:47 [inlined]
  [9] (::typeof(∂(params!)))(Δ::Nothing)
    @ Zygote ~/.julia/packages/Zygote/6HN9x/src/compiler/interface2.jl:0
 [10] Pullback
    @ ~/.julia/packages/Flux/6o4DQ/src/functor.jl:47 [inlined]
 [11] (::typeof(∂(params!)))(Δ::Nothing)
    @ Zygote ~/.julia/packages/Zygote/6HN9x/src/compiler/interface2.jl:0
 [12] Pullback
    @ ~/.julia/packages/Flux/6o4DQ/src/functor.jl:44 [inlined]
 [13] (::typeof(∂(params!)))(Δ::Nothing)
    @ Zygote ~/.julia/packages/Zygote/6HN9x/src/compiler/interface2.jl:0
 [14] Pullback
    @ ~/.julia/packages/Flux/6o4DQ/src/functor.jl:53 [inlined]
 [15] (::typeof(∂(params)))(Δ::Nothing)
    @ Zygote ~/.julia/packages/Zygote/6HN9x/src/compiler/interface2.jl:0
 [16] Pullback
    @ /media/jstrube/24988e98-7094-4b00-aeb9-5c98c5b52a901/Data/model-zoo/vision/vae_mnist/vae_mnist.jl:66 [inlined]
 [17] (::typeof(∂(model_loss)))(Δ::Float32)
    @ Zygote ~/.julia/packages/Zygote/6HN9x/src/compiler/interface2.jl:0
 [18] Pullback
    @ /media/jstrube/24988e98-7094-4b00-aeb9-5c98c5b52a901/Data/model-zoo/vision/vae_mnist/vae_mnist.jl:142 [inlined]
 [19] (::typeof(∂(λ)))(Δ::Float32)
    @ Zygote ~/.julia/packages/Zygote/6HN9x/src/compiler/interface2.jl:0
 [20] (::Zygote.var"#69#70"{Zygote.Params, typeof(∂(λ)), Zygote.Context})(Δ::Float32)
    @ Zygote ~/.julia/packages/Zygote/6HN9x/src/compiler/interface.jl:252
 [21] train(; kws::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Main /media/jstrube/24988e98-7094-4b00-aeb9-5c98c5b52a901/Data/model-zoo/vision/vae_mnist/vae_mnist.jl:144
 [22] train()
    @ Main /media/jstrube/24988e98-7094-4b00-aeb9-5c98c5b52a901/Data/model-zoo/vision/vae_mnist/vae_mnist.jl:94
 [23] top-level scope
    @ /media/jstrube/24988e98-7094-4b00-aeb9-5c98c5b52a901/Data/model-zoo/vision/vae_mnist/vae_mnist.jl:176
in expression starting at /media/jstrube/24988e98-7094-4b00-aeb9-5c98c5b52a901/Data/model-zoo/vision/vae_mnist/vae_mnist.jl:175

According to discourse, this can be fixed by adding Flux.Zygote.@nograd Flux.params before the function definition of model_loss. This indeed fixes it for me.

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.

1 participant