Gradient definitions & supertypes#168
Merged
Merged
Conversation
| @show Δ′ | ||
| # (Δ′, i,map(_ -> nothing, j)...) # surely that i is a bug? | ||
| (Δ′, nothing, map(_ -> nothing, j)...) | ||
| # (VectorOfArray(Δ′), nothing, map(_ -> nothing, j)...) |
Member
There was a problem hiding this comment.
why would it not be this one?
| Δ′ = zero(VA) | ||
| Δ′[i,j...] = Δ | ||
| (Δ′, i,map(_ -> nothing, j)...) | ||
| @show Δ′ |
Member
There was a problem hiding this comment.
Suggested change
| @show Δ′ |
Member
There was a problem hiding this comment.
oh no worries, still worth the downstream tests
Member
|
Thanks! Running downstream tests to check it out. |
| Δ′[i,j...] = Δ | ||
| (Δ′, i,map(_ -> nothing, j)...) | ||
| @show Δ′ | ||
| # (Δ′, i,map(_ -> nothing, j)...) # surely that i is a bug? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is inspired by SciML/SciMLSensitivity.jl#493 (comment) . I wrote many examples there, but the core surprise was that a
VectorOfArrays{T} <: AbstractArray{T,3}has a gradientVector{Matrix{T}}which is not a 3-array. If I understood correctly, it would desirable that the result be another VectorOfArray, i.e. somethingAbstractArray{T,3}which iterates like Vector{Matrix}.One way to do that would be using ProjectTo. But in fact I believe the Vector{Matrix} is being explicitly generated by a rule defined here, so perhaps it is simpler just to alter that rule to wrap this?
RFC, WIP, needs tests... and needs thought about other cases:
VectorOfArray(collect(eachslice(Δ))), to return a comparable object, i.e. one which broadcasts one way and iterates a different way. This would needProjectTo. It would also apply to things likegradient(va -> sum(abs, [1 2; 3 4] * va), VectorOfArray([[1,2], [3,4]])).va[:,1]expected to work? What should it return? The other way around should I think do this: