-
-
Notifications
You must be signed in to change notification settings - Fork 216
Closed
Labels
Description
It currently seems quite difficult to use Dicts with Zygote - at least I have trouble getting it to work at all. Here's a MWE where the Dict is obviously unnecessary but it illustrates my point nonetheless. I could be doing something wrong, however this is a common data structure used in a straightforward fashion.
using Zygote
w = randn(5)
function f(w)
d = Dict{Int, Float64}(i => v for (i,v) in enumerate(w))
sum([v for (_, v) in d])
end
gradient(f, w)Error: map is not defined on dictionaries.
Using iterator syntax for the sum instead of the list comprehension syntax gives: MethodError: no method matching getindex(::Dict{Any,Any}), which probably makes the issue similar to #408.