-
Notifications
You must be signed in to change notification settings - Fork 89
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
Make operations on BitArray's non-differentiable #293
Comments
It looks like that since julia> using Zygote
julia> gradient(x -> x, false) # bools are differentiable
(true,)
julia> gradient(x -> x + 1, false)
(1,)
julia> gradient(x -> sum(x), [false,false]) # array of bools are not
(nothing,)
julia> gradient(x -> x[1] + x[2], [false,false]) # this should give same result as previous line
([1, 1],) I'm ok with bools being not-differentiable, although they can be embedded in a differentiable manifold as much as e.g. integers Either way, we must handle consistently single bools and arrays of bools. Can we add the rules for no-grading bools to this repo? |
We have dozens of rules settings bools as nondifferentiable. |
Where are they? I tried to search for |
Yes it's a choice, but a useful one I think. (And it wasn't my idea!) Also a relatively new one, Zygote's initial behaviour was to treat all numbers alike, including promoting to Complex un-asked for, which (IMO) is extremely surprising. Grouping (Int8 ... Float64) as all representing mathematical reals (for AD) seems like a good policy to me. This does promote integers to the continuum, but they are often used as easy-to-write real numbers, e.g. nobody in calculus class is confused by Base treats bools specially in a few places, I guess the first is where we can claim moral precedent:
About adding rules, I'm still not entirely sure why the functions encoded in
or some more elegant version which handles BitArrays, Complex, and perhaps Diagonal, etc. (And keeps just the types, not the objects |
Here's how I hacked this into ZygoteRules at some point. This was for real/complex but could trivially include Bool: |
I also didn't see any, the only rule that I was already going to put in my next commit was:
|
Most of them that we have right now are for functions that return
One could, but it is beyond the scope of this issue. |
Bools are not a differentiable type,
thus nor are BitArray's
The text was updated successfully, but these errors were encountered: