I was originally trying to train a network with recurrence using GRUs but I kept getting this BoundsError: attempt to access Tuple{} at index [0]
. So I gave up and tried running the rnn-char
example in the model-zoo
, with the same results (also the code in the model zoo needs to be updated with params(m)
→ Flux.params(m)
):
[ Info: Start Training, total 2 epochs
[ Info: Epoch 1 / 2
ERROR: LoadError: BoundsError: attempt to access Tuple{} at index [0]
Stacktrace:
[1] getindex(t::Tuple, i::Int64)
@ Base ./tuple.jl:29
[2] last(a::Tuple{})
@ Base ./abstractarray.jl:479
[3] rrule(config::Zygote.ZygoteRuleConfig{Zygote.Context{true}}, ::typeof(foldl), op::Base.var"#57#58"{typeof(Flux.reset!)}, x::Tuple{}; init::Nothing)
@ ChainRules ~/.julia/packages/ChainRules/hVHC4/src/rulesets/Base/mapreduce.jl:448
[4] chain_rrule_kw
@ ~/.julia/packages/Zygote/dABKa/src/compiler/chainrules.jl:230 [inlined]
[5] macro expansion
@ ~/.julia/packages/Zygote/dABKa/src/compiler/interface2.jl:0 [inlined]
[6] _pullback(::Zygote.Context{true}, ::Base.var"#foldl##kw", ::NamedTuple{(:init,), Tuple{Nothing}}, ::typeof(foldl), ::Base.var"#57#58"{typeof(Flux.reset!)}, ::Tuple{})
@ Zygote ~/.julia/packages/Zygote/dABKa/src/compiler/interface2.jl:9
[7] _pullback
@ ./tuple.jl:555 [inlined]
[8] _pullback(::Zygote.Context{true}, ::typeof(foreach), ::typeof(Flux.reset!), ::Tuple{})
@ Zygote ~/.julia/packages/Zygote/dABKa/src/compiler/interface2.jl:0
[9] _pullback
@ ~/.julia/packages/Flux/FKl3M/src/layers/recurrent.jl:180 [inlined]
[10] _pullback(ctx::Zygote.Context{true}, f::typeof(Flux.reset!), args::Matrix{Float32})
@ Zygote ~/.julia/packages/Zygote/dABKa/src/compiler/interface2.jl:0
[11] _pullback
@ ./abstractarray.jl:2774 [inlined]
[12] _pullback(::Zygote.Context{true}, ::typeof(foreach), ::typeof(Flux.reset!), ::NamedTuple{(:weight, :bias, :σ), Tuple{Matrix{Float32}, Vector{Float32}, typeof(identity)}})
@ Zygote ~/.julia/packages/Zygote/dABKa/src/compiler/interface2.jl:0
[13] _pullback
@ ~/.julia/packages/Flux/FKl3M/src/layers/recurrent.jl:180 [inlined]
[14] _pullback
@ ./tuple.jl:555 [inlined]
[15] #rrule_via_ad#46
@ ~/.julia/packages/Zygote/dABKa/src/compiler/chainrules.jl:255 [inlined]
[16] rrule_via_ad
@ ~/.julia/packages/Zygote/dABKa/src/compiler/chainrules.jl:243 [inlined]
[17] #1703
@ ~/.julia/packages/ChainRules/hVHC4/src/rulesets/Base/mapreduce.jl:444 [inlined]
[18] BottomRF
@ ./reduce.jl:81 [inlined]
[19] #837
@ ./accumulate.jl:291 [inlined]
[20] afoldl
@ ./operators.jl:550 [inlined]
[21] #accumulate#836
@ ./accumulate.jl:290 [inlined]
[22] #rrule#1702
@ ~/.julia/packages/ChainRules/hVHC4/src/rulesets/Base/mapreduce.jl:440 [inlined]
[23] chain_rrule_kw
@ ~/.julia/packages/Zygote/dABKa/src/compiler/chainrules.jl:230 [inlined]
[24] macro expansion
@ ~/.julia/packages/Zygote/dABKa/src/compiler/interface2.jl:0 [inlined]
[25] _pullback
@ ~/.julia/packages/Zygote/dABKa/src/compiler/interface2.jl:9 [inlined]
[26] _pullback
@ ./tuple.jl:555 [inlined]
[27] _pullback(::Zygote.Context{true}, ::typeof(foreach), ::typeof(Flux.reset!), ::Tuple{Flux.Recur{Flux.LSTMCell{Matrix{Float32}, Matrix{Float32}, Vector{Float32}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Flux.Recur{Flux.LSTMCell{Matrix{Float32}, Matrix{Float32}, Vector{Float32}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Dense{typeof(identity), Matrix{Float32}, Vector{Float32}}})
@ Zygote ~/.julia/packages/Zygote/dABKa/src/compiler/interface2.jl:0
[28] _pullback
@ ~/.julia/packages/Flux/FKl3M/src/layers/recurrent.jl:180 [inlined]
[29] _pullback(ctx::Zygote.Context{true}, f::typeof(Flux.reset!), args::Tuple{Flux.Recur{Flux.LSTMCell{Matrix{Float32}, Matrix{Float32}, Vector{Float32}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Flux.Recur{Flux.LSTMCell{Matrix{Float32}, Matrix{Float32}, Vector{Float32}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Dense{typeof(identity), Matrix{Float32}, Vector{Float32}}})
@ Zygote ~/.julia/packages/Zygote/dABKa/src/compiler/interface2.jl:0
[30] _pullback
@ ./abstractarray.jl:2774 [inlined]
[31] _pullback(::Zygote.Context{true}, ::typeof(foreach), ::typeof(Flux.reset!), ::NamedTuple{(:layers,), Tuple{Tuple{Flux.Recur{Flux.LSTMCell{Matrix{Float32}, Matrix{Float32}, Vector{Float32}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Flux.Recur{Flux.LSTMCell{Matrix{Float32}, Matrix{Float32}, Vector{Float32}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Dense{typeof(identity), Matrix{Float32}, Vector{Float32}}}}})
@ Zygote ~/.julia/packages/Zygote/dABKa/src/compiler/interface2.jl:0
[32] _pullback
@ ~/.julia/packages/Flux/FKl3M/src/layers/recurrent.jl:180 [inlined]
[33] _pullback
@ ~/Projects/model-zoo/text/char-rnn/char-rnn.jl:111 [inlined]
[34] _pullback(::Zygote.Context{true}, ::var"#loss#9"{Chain{Tuple{Flux.Recur{Flux.LSTMCell{Matrix{Float32}, Matrix{Float32}, Vector{Float32}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Flux.Recur{Flux.LSTMCell{Matrix{Float32}, Matrix{Float32}, Vector{Float32}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Dense{typeof(identity), Matrix{Float32}, Vector{Float32}}}}}, ::SubArray{Vector{OneHotArrays.OneHotVector{UInt32}}, 1, Vector{Vector{OneHotArrays.OneHotVector{UInt32}}}, Tuple{UnitRange{Int64}}, true}, ::SubArray{Vector{OneHotArrays.OneHotVector{UInt32}}, 1, Vector{Vector{OneHotArrays.OneHotVector{UInt32}}}, Tuple{UnitRange{Int64}}, true})
@ Zygote ~/.julia/packages/Zygote/dABKa/src/compiler/interface2.jl:0
[35] _apply(::Function, ::Vararg{Any})
@ Core ./boot.jl:816
[36] adjoint
@ ~/.julia/packages/Zygote/dABKa/src/lib/lib.jl:203 [inlined]
[37] _pullback
@ ~/.julia/packages/ZygoteRules/AIbCs/src/adjoint.jl:65 [inlined]
[38] _pullback
@ ~/.julia/packages/Flux/FKl3M/src/optimise/train.jl:132 [inlined]
[39] _pullback(::Zygote.Context{true}, ::Flux.Optimise.var"#37#40"{var"#loss#9"{Chain{Tuple{Flux.Recur{Flux.LSTMCell{Matrix{Float32}, Matrix{Float32}, Vector{Float32}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Flux.Recur{Flux.LSTMCell{Matrix{Float32}, Matrix{Float32}, Vector{Float32}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Dense{typeof(identity), Matrix{Float32}, Vector{Float32}}}}}, Tuple{SubArray{Vector{OneHotArrays.OneHotVector{UInt32}}, 1, Vector{Vector{OneHotArrays.OneHotVector{UInt32}}}, Tuple{UnitRange{Int64}}, true}, SubArray{Vector{OneHotArrays.OneHotVector{UInt32}}, 1, Vector{Vector{OneHotArrays.OneHotVector{UInt32}}}, Tuple{UnitRange{Int64}}, true}}})
@ Zygote ~/.julia/packages/Zygote/dABKa/src/compiler/interface2.jl:0
[40] pullback(f::Function, ps::Zygote.Params{Zygote.Buffer{Any, Vector{Any}}})
@ Zygote ~/.julia/packages/Zygote/dABKa/src/compiler/interface.jl:373
[41] withgradient(f::Function, args::Zygote.Params{Zygote.Buffer{Any, Vector{Any}}})
@ Zygote ~/.julia/packages/Zygote/dABKa/src/compiler/interface.jl:123
[42] macro expansion
@ ~/.julia/packages/Flux/FKl3M/src/optimise/train.jl:131 [inlined]
[43] macro expansion
@ ~/.julia/packages/ProgressLogging/6KXlp/src/ProgressLogging.jl:328 [inlined]
[44] train!(loss::Function, ps::Zygote.Params{Zygote.Buffer{Any, Vector{Any}}}, data::Base.Iterators.Zip{Tuple{Vector{SubArray{Vector{OneHotArrays.OneHotVector{UInt32}}, 1, Vector{Vector{OneHotArrays.OneHotVector{UInt32}}}, Tuple{UnitRange{Int64}}, true}}, Vector{SubArray{Vector{OneHotArrays.OneHotVector{UInt32}}, 1, Vector{Vector{OneHotArrays.OneHotVector{UInt32}}}, Tuple{UnitRange{Int64}}, true}}}}, opt::Adam; cb::Flux.var"#throttled#124"{Flux.var"#throttled#120#125"{Bool, Bool, var"#8#11"{SubArray{Vector{OneHotArrays.OneHotVector{UInt32}}, 1, Vector{Vector{OneHotArrays.OneHotVector{UInt32}}}, Tuple{UnitRange{Int64}}, true}, SubArray{Vector{OneHotArrays.OneHotVector{UInt32}}, 1, Vector{Vector{OneHotArrays.OneHotVector{UInt32}}}, Tuple{UnitRange{Int64}}, true}, var"#loss#9"{Chain{Tuple{Flux.Recur{Flux.LSTMCell{Matrix{Float32}, Matrix{Float32}, Vector{Float32}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Flux.Recur{Flux.LSTMCell{Matrix{Float32}, Matrix{Float32}, Vector{Float32}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Tuple{Matrix{Float32}, Matrix{Float32}}}, Dense{typeof(identity), Matrix{Float32}, Vector{Float32}}}}}}, Int64}})
@ Flux.Optimise ~/.julia/packages/Flux/FKl3M/src/optimise/train.jl:129
[45] train(; kws::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Main ~/Projects/model-zoo/text/char-rnn/char-rnn.jl:123
[46] train()
@ Main ~/Projects/model-zoo/text/char-rnn/char-rnn.jl:100
[47] top-level scope
@ ~/Projects/model-zoo/text/char-rnn/char-rnn.jl:168
in expression starting at /Users/mjyshin/Projects/model-zoo/text/char-rnn/char-rnn.jl:168
Anyone have any idea what’s going on? I have the following environment with Julia 1.8.2:
(julia) pkg> status
Status `~/Projects/test/julia/Project.toml`
[587475ba] Flux v0.13.8
[7073ff75] IJulia v1.23.3
[b964fa9f] LaTeXStrings v1.3.0
[d96e819e] Parameters v0.12.3
[91a5bcdd] Plots v1.36.3
[2913bbd2] StatsBase v0.33.21
[e88e6eb3] Zygote v0.6.49