3 ms·
This looks neat . In python is this also a project that does the same thing ? https://github.com/HIPS/autograd https://github.com/HIPS/autograd
by zitterbewegung 7y ago
This looks neat . In python is this also a project that does the same thing ? https://github.com/HIPS/autograd https://github.com/HIPS/autograd
- deleted 7y ago[deleted]
- phrmoy 7y agoWould also be curious to understand how this compares. They seem to account for recursion and if-branches as well.
- eigenspace 7y agoThey're not really all that close. For instance that Autograd library requires that you use its own version of numpy instead of the regular version because it can't differentiate C. Because most non-trivial python code is actually written in C, there's almost no performant programs you can just differentiate out of the box unless autograd itself has a fork of that package. My understanding is that the python Autograd library is also quite slow (though it's been a while since I looked at it). Zygote will give the same runtime performance as handwritten derivatives in many cases and works across almost the entire julia ecosystem since nearly all julia packages are truly written in julia.
- phrmoy 7y agothank you.
- shoyer 7y agoJAX (github.com/google/jax), which is being developed by many of the authors of Autograd, is a probably a better comparison. At the cost of requiring you to rewrite control flow in a functional way, it eliminates Python's overhead by compiling NumPy code into XLA.
- ddragon 7y agoAutograd (and most of the current approaches) work by having a special object for the data and overloaded methods that instead of immediately executing an operation they instead store it in a graph of transformations. Then when you need the gradient it applies the chain rule over this graph. The support for loops/control flow is possible since at each call you destroy and recreate the graph, which is not optimal for performance but makes it very dynamic (tensorflow eager/pytorch vs tensorflow graph interface). That's also an approach that Julia excels because of multiple dispatch which you can see explained in [1]. In that case you have effectively two separate languages, the language used to generate the graph and the graph, each. This approach applies the transformation directly on the Julia IR to generate the gradient descent as if you wrote it directly on Julia side by side with the code that was written in a way that is completely unaware of that transformation (such as the ability to differentiate libraries that were built before that approach even existed). So the end product is something that is similar to the tensorflow graph (it has all control flow already embedded and can be pre-optimized by a compiler), but that is even easier to write than tensorflow eager (which is also the intent of Swift for Tensorflow). [1] https://github.com/MikeInnes/diff-zoo https://github.com/MikeInnes/diff-zoo