-
Notifications
You must be signed in to change notification settings - Fork 27
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
unsupported keyword argument "time" when taking a gradient with Zygote #140
Comments
MWE is this: julia> using Zygote, NamedDims
julia> gradient(x -> x[1], NamedDimsArray(rand(3), :a)) # easy case
(NamedDimsArray([1.0, 0.0, 0.0], :a),)
julia> gradient(x -> x[a=1], NamedDimsArray(rand(3), :a))
ERROR: MethodError: no method matching adjoint(::Zygote.Context{false}, ::typeof(getindex), ::NamedDimsArray{(:a,), Float64, 1, Vector{Float64}}; a::Int64)
Closest candidates are:
adjoint(::ZygoteRules.AContext, ::typeof(getindex), ::AbstractArray, ::Any...) got unsupported keyword argument "a" Ideally Zygote would treat this call as not having a rule, and keep going, to see later calls to getindex without keywords. On some level keywords don't participate in dispatch, but e.g. something like this julia> using ChainRulesCore
julia> rrule(getindex, NamedDimsArray(rand(3), :a), 1) # easy case
(0.48728253527621856, ChainRules.var"#getindex_pullback#1601"{NamedDimsArray{(:a,), Float64, 1, Vector{Float64}}, Tuple{Int64}, Tuple{NoTangent}}(NamedDimsArray([0.48728253527621856, 0.20976131397698006, 0.6193363603857295], :a), (1,), (NoTangent(),)))
julia> rrule(getindex, NamedDimsArray(rand(3), :a); a=1) # nothing, as if no rule
julia> rrule(getindex, NamedDimsArray(rand(3), :a)) # same positional arguments, without keyword
ERROR: BoundsError: attempt to access 3-element Vector{Float64} at index [] That's not how Zygote works, because (1) it's using its own |
Doing the following outputs a reasonable error? Any hints? Doing a similar function without AxisKeys works, however the advantage of using the
time
dimension is lost, which I would like to keep.I suppose that I will need a new rule, however not sure how to actually start doing it.
The text was updated successfully, but these errors were encountered: