-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
broken iteration over dictionary #1065
Comments
This showed up in JuliaNonconvex/Nonconvex.jl#130 so just giving it a bump. |
Dict handling is one of the most finicky bits of Zygote's internals and issues which involve the AD transform even more so. I'm not even sure any active contributors understand the latter in enough depth to easily root cause issues like this. Nonetheless, will try to have a look at it next week. |
any update here? |
Had another look today and surprisingly it seems |
Awesome! |
I have a similar small code example (*): using Zygote
my_dict = Dict(
"name1" => 1.,
"name2" => 2.,
)
function my_func(x)
result = 0
for (xᵢ, (name, value)) in zip(x, my_dict)
result += value * xᵢ
end
return result
end
my_func([3., 4.])
Zygote.gradient(my_func, [3., 4.]) Error message:
Have I understood correctly that iterating over dictionaries is currently not supported? (*) I know I should not use global variables. This is just a small part of something I'm trying to realise using a closure, but I wanted to simplify the example. |
Interestingly, the code works correctly with named tuples (i. e. removing the |
Have you tried the linked PR? |
No, sorry. I could circumvent the problem by leaving the |
closing as it seems #1285 fixed both examples in the OP |
Issue related to #725 :
Also iteration using
values
is broken:The text was updated successfully, but these errors were encountered: