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

ConvTranspose gradient error: no method matching iterate(::Nothing) #900

Closed
jumerckx opened this issue Oct 19, 2019 · 3 comments
Closed

Comments

@jumerckx
Copy link

This code fails with ERROR: MethodError: no method matching iterate(::Nothing)

using Flux

m = ConvTranspose((3,3), 2=>1)
x = rand(10,10,2,1)

gradient(()->sum(m(x)), params(m))

Here's the full stacktrace:

julia> gradient(()->sum(m(x)), params(m))
ERROR: MethodError: no method matching iterate(::Nothing)
Closest candidates are:
  iterate(::Core.SimpleVector) at essentials.jl:568
  iterate(::Core.SimpleVector, ::Any) at essentials.jl:568
  iterate(::ExponentialBackOff) at error.jl:199
  ...
Stacktrace:
 [1] _zip_iterate_some at .\iterators.jl:350 [inlined]
 [2] _zip_iterate_all at .\iterators.jl:342 [inlined]
 [3] iterate at .\iterators.jl:332 [inlined]
 [4] iterate at .\generator.jl:44 [inlined]
 [5] collect(::Base.Generator{Base.Iterators.Zip{Tuple{Array{typeof(∂(λ)),1},Nothing}},getfield(Base, Symbol("##3#4")){getfield(Zygote, Symbol("##945#949"))}}) at .\array.jl:606
 [6] map(::Function, ::Array{typeof(∂(λ)),1}, ::Nothing) at .\abstractarray.jl:2091
 [7] (::getfield(Zygote, Symbol("##944#948")){Array{typeof(∂(λ)),1}})(::Nothing) at C:\Users\jules\.julia\packages\Zygote\lRotY\src\lib\array.jl:121
 [8] (::getfield(Zygote, Symbol("##952#953")){getfield(Zygote, Symbol("##944#948")){Array{typeof(∂(λ)),1}}})(::Nothing) at C:\Users\jules\.julia\packages\Zygote\lRotY\src\lib\array.jl:136
 [9] getindex at .\tuple.jl:26 [inlined]
 [10] (::typeof(∂(getindex)))(::Nothing) at C:\Users\jules\.julia\packages\Zygote\lRotY\src\compiler\interface2.jl:0
 [11] (::typeof(∂(Flux.conv_transpose_dims)))(::Nothing) at C:\Users\jules\.julia\packages\Flux\WxpHb\src\layers\conv.jl:109
 [12] (::typeof(∂(λ)))(::FillArrays.Fill{Float64,4,NTuple{4,Base.OneTo{Int64}}}) at C:\Users\jules\.julia\packages\Flux\WxpHb\src\layers\conv.jl:124
 [13] #27 at .\none:1 [inlined]
 [14] (::typeof(∂(getfield(Main, Symbol("##27#28"))())))(::Float64) at C:\Users\jules\.julia\packages\Zygote\lRotY\src\compiler\interface2.jl:0
 [15] (::getfield(Zygote, Symbol("##38#39")){Zygote.Params,Zygote.Context,typeof(∂(getfield(Main, Symbol("##27#28"))()))})(::Float64) at C:\Users\jules\.julia\packages\Zygote\lRotY\src\compiler\interface.jl:101
 [16] gradient(::Function, ::Zygote.Params) at C:\Users\jules\.julia\packages\Zygote\lRotY\src\compiler\interface.jl:47
 [17] top-level scope at none:0
@MikeInnes
Copy link
Member

Due to an issue in this function. We could just @nograd, but it'd be good to figure out why Zygote is failing here.

@xukai92
Copy link

xukai92 commented Nov 9, 2019

Yes for now I just do Flux.Zygote.@nograd Flux.conv_transpose_dims to fix this.

@bors bors bot closed this as completed in fb4a48f Nov 26, 2019
@kczimm
Copy link

kczimm commented Jan 17, 2020

My problem led me to this issue which results in the same error. If it's not a bug but me, perhaps it should stay here or otherwise go in a different issue? I'm not sure.

using Flux

m = Dense(2, 2, x->log.(max.(eps.(x), x)))
x = rand(2)

gradient(()->sum(m(x)), params(m))
ERROR: LoadError: MethodError: no method matching iterate(::Nothing)
Closest candidates are:
  iterate(!Matched::Core.SimpleVector) at essentials.jl:600
  iterate(!Matched::Core.SimpleVector, !Matched::Any) at essentials.jl:600
  iterate(!Matched::ExponentialBackOff) at error.jl:218
  ...
Stacktrace:
 [1] (::Zygote.var"#1589#1591"{Zygote.var"#59#78"})(::Float32) at /home/kevin/.julia/packages/Zygote/oMScO/src/lib/broadcast.jl:140
 [2] (::Zygote.var"#3946#back#1592"{Zygote.var"#1589#1591"{Zygote.var"#59#78"}})(::Float32) at /home/kevin/.julia/packages/ZygoteRules/6nssF/src/adjoint.jl:49
 [3] (::Zygote.var"#157#158"{Zygote.var"#3946#back#1592"{Zygote.var"#1589#1591"{Zygote.var"#59#78"}},Tuple{Tuple{Nothing,Nothing,Nothing},Tuple{}}})(::Float32) at /home/kevin/.julia/packages/Zygote/oMScO/src/lib/lib.jl:156
 [4] (::Zygote.var"#297#back#159"{Zygote.var"#157#158"{Zygote.var"#3946#back#1592"{Zygote.var"#1589#1591"{Zygote.var"#59#78"}},Tuple{Tuple{Nothing,Nothing,Nothing},Tuple{}}}})(::Float32) at /home/kevin/.julia/packages/ZygoteRules/6nssF/src/adjoint.jl:49
 [5] broadcasted at ./broadcast.jl:1231 [inlined]
 [6] #7 at /tmp/mwe.jl:3 [inlined]
 [7] (::typeof(∂(#7)))(::Float32) at /home/kevin/.julia/packages/Zygote/oMScO/src/compiler/interface2.jl:0
 [8] (::Zygote.var"#1576#1583")(::typeof(∂(#7)), ::Float32) at /home/kevin/.julia/packages/Zygote/oMScO/src/lib/broadcast.jl:129
 [9] (::Base.var"#3#4"{Zygote.var"#1576#1583"})(::Tuple{typeof(∂(#7)),Float32}) at ./generator.jl:36
 [10] iterate at ./generator.jl:47 [inlined]
 [11] collect at ./array.jl:622 [inlined]
 [12] map at ./abstractarray.jl:2155 [inlined]
 [13] (::Zygote.var"#1575#1582"{Tuple{Array{Float32,1}},Val{2},Array{typeof(∂(#7)),1}})(::FillArrays.Fill{Float32,1,Tuple{Base.OneTo{Int64}}}) at /home/kevin/.julia/packages/Zygote/oMScO/src/lib/broadcast.jl:129
 [14] (::Zygote.var"#3934#back#1586"{Zygote.var"#1575#1582"{Tuple{Array{Float32,1}},Val{2},Array{typeof(∂(#7)),1}}})(::FillArrays.Fill{Float32,1,Tuple{Base.OneTo{Int64}}}) at /home/kevin/.julia/packages/ZygoteRules/6nssF/src/adjoint.jl:49
 [15] (::Zygote.var"#157#158"{Zygote.var"#3934#back#1586"{Zygote.var"#1575#1582"{Tuple{Array{Float32,1}},Val{2},Array{typeof(∂(#7)),1}}},Tuple{Tuple{Nothing,Nothing,Nothing},Tuple{}}})(::FillArrays.Fill{Float32,1,Tuple{Base.OneTo{Int64}}}) at /home/kevin/.julia/packages/Zygote/oMScO/src/lib/lib.jl:156
 [16] (::Zygote.var"#297#back#159"{Zygote.var"#157#158"{Zygote.var"#3934#back#1586"{Zygote.var"#1575#1582"{Tuple{Array{Float32,1}},Val{2},Array{typeof(∂(#7)),1}}},Tuple{Tuple{Nothing,Nothing,Nothing},Tuple{}}}})(::FillArrays.Fill{Float32,1,Tuple{Base.OneTo{Int64}}}) at /home/kevin/.julia/packages/ZygoteRules/6nssF/src/adjoint.jl:49
 [17] broadcasted at ./broadcast.jl:1231 [inlined]
 [18] Dense at /home/kevin/.julia/packages/Flux/2i5P1/src/layers/basic.jl:102 [inlined]
 [19] (::typeof(∂(invoke)))(::FillArrays.Fill{Float32,1,Tuple{Base.OneTo{Int64}}}) at /home/kevin/.julia/packages/Zygote/oMScO/src/compiler/interface2.jl:0
 [20] Dense at /home/kevin/.julia/packages/Flux/2i5P1/src/layers/basic.jl:113 [inlined]
 [21] (::typeof(∂(λ)))(::FillArrays.Fill{Float32,1,Tuple{Base.OneTo{Int64}}}) at /home/kevin/.julia/packages/Zygote/oMScO/src/compiler/interface2.jl:0
 [22] Dense at /home/kevin/.julia/packages/Flux/2i5P1/src/layers/basic.jl:116 [inlined]
 [23] (::typeof(∂(λ)))(::FillArrays.Fill{Float32,1,Tuple{Base.OneTo{Int64}}}) at /home/kevin/.julia/packages/Zygote/oMScO/src/compiler/interface2.jl:0
 [24] #9 at /tmp/mwe.jl:6 [inlined]
 [25] (::typeof(∂(#9)))(::Float32) at /home/kevin/.julia/packages/Zygote/oMScO/src/compiler/interface2.jl:0
 [26] (::Zygote.var"#38#39"{Zygote.Params,Zygote.Context,typeof(∂(#9))})(::Float32) at /home/kevin/.julia/packages/Zygote/oMScO/src/compiler/interface.jl:101
 [27] gradient(::Function, ::Zygote.Params) at /home/kevin/.julia/packages/Zygote/oMScO/src/compiler/interface.jl:47
 [28] top-level scope at /tmp/mwe.jl:6
 [29] include at ./boot.jl:328 [inlined]
 [30] include_relative(::Module, ::String) at ./loading.jl:1105
 [31] include(::Module, ::String) at ./Base.jl:31
 [32] exec_options(::Base.JLOptions) at ./client.jl:287
 [33] _start() at ./client.jl:460

I'm running Ubuntu with Julia v1.3.0 and Flux v0.10.1.

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

No branches or pull requests

4 participants