Skip to content

bug in comprehension over dictionaries #725

@rlrs

Description

@rlrs

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions