Comments (4)
Just added fairly comprehensive interface documentation to the docs. Let me know if there's anything unclear in that.
from zygote.jl.
No other docs yet, but I can try to clarify these and figure out what needs documenting explicitly.
In general we specify the args we want using closures, e.g.
f(a, b) = a*b
gradient(f, 2, 3) # (3, 2)
gradient(x -> f(2, x), 3) # (2,)
This is one of those things that makes total sense but is a bit non-obvious at first, so it'd be worth having explicit docs on this.
I'm a bit confused by the other two questions; the gradients are right there, and running without gradients is just f(2, 3)
as usual. Maybe you're referring to the Params
API which is a bit different.
It might be useful to see how I'd simulate Knet/AutoGrad's original API with Zygote:
grad(f, arg = 1) = (x...) -> gradient(f, x...)[arg]
loss(θ, x) = sum(θ[:W] * x .+ θ[:b])
∇loss = grad(loss)
θ = Dict(:W => randn(5,5), :b => randn(5))
# θ = (W = randn(5,5), b = randn(5)) # NamedTuples work too
∇loss(θ, rand(5)) # Dict(:W => ..., :b => ...)
from zygote.jl.
from zygote.jl.
All fair points. I've mostly been focusing on compiler crashes up to now, but things are getting more usable so it's time to add these kinds of docstrings.
Yes, you can always take the gradient of a structure; things like dropping keys are technically a library-level issue but we will drop keys of dicts right now. We also return nothing
in the case that a value is not used at all; I'm not completely set on that but up to now it seems like a reasonable way forward.
I am wondering if we can write a 5 line mini-Zygote example in Julia
Yeah this is a good idea. It's not easy to write down the code transformation, but it is pretty easy to simulate what Zygote is doing by hand, so it'd be good to have a notebook or some docs on that.
from zygote.jl.
Related Issues (20)
- `repeat(X; outer, inner)` triggers scalar indexing error with CUDA HOT 1
- Missing support for muladd in case of brodcasting with a complex argument HOT 1
- `nothing` in output of a `pullback` HOT 2
- Assignment to multiple arrays is not differentiable on GPU since Zygote.jl 0.6.67 HOT 5
- Spurious "Output is complex, so the gradient is not defined" error HOT 2
- NaN in gradient of abs() on complex 0 HOT 1
- Pullback on mean() gives illegal memory access code 700 HOT 32
- test
- Type unstable gradients (@code_warntype) HOT 1
- Type unstable gradients HOT 1
- Zygote gradients different from ForwardDiff/ReverseDiff on Julia 1.10-rc2 HOT 3
- try/catch is not supported when attempting to use `remake` with Zygote HOT 1
- gradient of SVD not working for complex input HOT 1
- `Zygote` doesn't properly work with `Metal.jl` and half precision. HOT 4
- `gradient` broken for `(*)(::Diagonal{Real}, ::Matrix{Complex}, ::Diagonal{Real})` when updating Julia 1.8 -> 1.9 HOT 6
- Method ambiguities reported by Aqua
- slow/high allocation gradient with mapreduce and iterators HOT 11
- error in summation of product iterator HOT 2
- `sort(x; rev=true)` is not supported HOT 1
- Incorrect gradients for `plan_rfft(x) * x` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zygote.jl.