HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
HIPS
autograd
Python2015–2023
HIPS / autograd

autograd

Efficiently computes derivatives of NumPy code.

18Distinct people
21Mentions
1Explicit recommenders
7.6KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Efficiently computes derivatives of NumPy code.

GitHub

Where it is used

No documented product use was verified in the last source check.

What people are saying

I love the discussion thread on GitHub: https://github.com/HIPS/autograd/pull/175#issuecomment-30652... As someone just starting to study machine learning it's inspiring and…

davedx used a recommendation phrase. One indexed comment matches. This is a phrase match, not a verdict.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

Mentioned in the same Hacker News threads. That is not proof they are substitutes.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 3:56:07 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year21 dated mentions

Observed mentions: 2015-05-12 08:42:52 UTC to 2023-10-02 17:28:27 UTC.

02462015-01-01 00:00:00 UTC to 2016-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20152016-01-01 00:00:00 UTC to 2017-01-01 00:00:00 UTC (exclusive): 3 mentions; 1 submissions, 2 comments2017-01-01 00:00:00 UTC to 2018-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 6 mentions; 0 submissions, 6 comments2019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 3 mentions; 1 submissions, 2 comments20192020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2023

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20152015-01-01 00:00:00 UTC2016-01-01 00:00:00 UTC101
20162016-01-01 00:00:00 UTC2017-01-01 00:00:00 UTC312
20172017-01-01 00:00:00 UTC2018-01-01 00:00:00 UTC101
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC606
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC312
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC202
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC101
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC202
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC202

From the project README

An excerpt from the repository, fetched Nov 13, 2026.

Read the project’s introduction
Autograd Autograd can automatically differentiate native Python and Numpy code. It can handle a large subset of Python's features, including loops, ifs, recursion and closures, and it can even take derivatives of derivatives of derivatives. It supports reverse-mode differentiation (a.k.a. backpropagation), which means it can efficiently take gradients of scalar-valued functions with respect to array-valued arguments, as well as forward-mode differentiation, and the two can be composed arbitrarily. The main intended application of Autograd is gradient-based optimization. For more information, check out the tutorial and the examples directory. Example use: >>> import autograd.numpy as np # Thinly-wrapped numpy >>> from autograd import grad # The only autograd function you may ever need >>> >>> def tanh(x): # Define a function ... return (1.0 - np.exp((-2 * x))) / (1.0 + np.exp(-(2 * x))) ... >>> grad_tanh = grad(tanh) # Obtain its gradient function >>> grad_tanh(1.0) # Evaluate the gradient at x = 1.0 np.float64(0.419974341614026) >>> (tanh(1.0001) - tanh(0.9999)) / 0.0002 # Compare to finite differences np.float64(0.41997434264973155) We can continue to differentiate as many times as we like, and use numpy's vectorization of scalar-valued functions across many different input values: >>> from autograd import elementwise_grad as egrad # for functions that vectorize over inputs >>> import matplotlib.pyplot as plt >>> x = np.linspace(-7, 7, 700) >>> plt.plot(x, tanh(x), ... x, egrad(tanh)(x), # first derivative ... x, egrad(egrad(tanh))(x), # second derivative ... x, egrad(egrad(egrad(tanh)))(x), # third derivative ... x, egrad(egrad(egrad(egrad(tanh))))(x),) # fourth derivative >>> plt.show() See the tanh example file for the code. Documentation You can find a tutorial here. End-to-end examples Simple neural net Convolutional neural net Recurrent neural net LSTM Neural Turing Machine Backpropagating through a fluid simulation Variational inference in Bayesian neural network Gaussian process regression Sampyl, a pure Python MCMC package with HMC and NUTS How to install Install Autograd using Pip: pip install autograd Some features require SciPy, which you can install separately or as an optional dependency along with Autograd: pip install "autograd[scipy]" Authors and maintainers Autograd was written by Dougal Maclaurin, David Duvenaud, Matt Johnson, Jamie Townsend and many other contributors. The package is currently being maintained by Agriya Khetarpal, Fabian Joswig and Jamie Townsend. Please feel free to submit any bugs or feature requests. We'd also love to hear about your experiences with Autograd in general. Drop us an email! We want to thank Jasper Snoek and the rest of the HIPS group (led by Prof. Ryan P. Adams) for helpful contributions and advice; Barak Pearlmutter for foundational work on automatic differentiation and for guidance on our implementation; and Analog Devices Inc. (Lyric Labs) and Samsung Advanced Institute of Technology for their generous support.
Read the full README on GitHub

What Hacker News says

21 sources
I'm sure there's a lot of good material around, but here are some links that are conceptually very close to the linked Autodidax. (Disclaimer: I wrote Autodidax and some of these other materials.) There's Autodidact [0], a predecessor to Autodidax, which was a simplified implementation of the original Autograd [1]. It focuses on reverse-mode autodiff, not building an open-ended transformation system like Autodidax. It's also pretty close to the content in these lecture slides [2] and this talk [3]. But the autodiff in Autodidax is more sophisticated and reflects clearer thinking. In particular, Autodidax shows how to implement forward- and reverse-modes using only one set of linearization rules (like in [4]). There's an even smaller and more recent variant [5], a single ~100 line file for reverse-mode AD on top of NumPy, which was live-co
Read the rest
In Autodidax: JAX core from scratch
They solve different problems. Numba compiles functions down to machine code or cuda kernels, that's it. XLA is "higher level" than what Numba produces. You may be able to get the equivalent of jax via numba+numpy+autograd[1], but I haven't tried it before. IMHO, jax is best thought of as a numerical computation library that happens to include autograd, vmapping, pmapping and provides a high level interface for XLA. I have built a numerical optimisation library with it, and although a few things became verbose, it was a rather pleasant experience as the natural vmapping made everything a breeze, I didn't have to write the gradients for my testing functions, except for special cases that involved exponents and logs that needed a bit of delicate care. [1] https://github.com/HIPS/autograd
In Numba: A High Performance Python Compiler
The difference is that in TF1 you had to use tf.cond, tf.while_loop etc for differentiable control flow. In JAX you can differentiate Python control flow directly, e.g.: In [1]: from jax import grad In [2]: def f(x): ...: if x > 0: ...: return 3. * x ** 2 ...: else: ...: return 5. * x ** 3 ...: In [3]: grad(f)(1.) Out[3]: DeviceArray(6., dtype=float32) In [4]: grad(f)(-1.) Out[4]: DeviceArray(15., dtype=float32) In the above example, the control flow happens in Python, just as it would in PyTorch. (That's not surprising, since JAX grew out of the original Autograd [1]!) Structured control flow functions like lax.cond, lax.scan, etc exist so that you can, for example, stage control flow out of Python and into an end-to-end compiled XLA computation with jax.jit. In other
Read the rest
words, some JAX transformations place more constraints on your Python code than others, but you can just opt into the ones you want. (More generally, the lax module lets you program XLA HLO pretty directly [2].) Disclaimer: I work on JAX! [1] https://github.com/hips/autograd [2] https://www.tensorflow.org/xla/operation_semantics
In Swift for TensorFlow – A system for deep learning and differentiable computing
Defining a loss function comes to mind. Checkout JAX[1] or Autograd[2]. As this is essentially a different programming paradigm there are a ton of opportunities, but it is fresh enough such that there is little to no history of software engineering differentiable programs. Design patterns, rules of thumb, and standard practices have yet to be defined. [1] https://github.com/google/jax [2] https://github.com/HIPS/autograd
In Demystifying Differentiable Programming (2018)
Automatic Differentiation is an algorithm to efficiently compute the value of the derivative of a function implemented by some arbitrary code. It does not use numerical approximation; it combines algorithmic cleverness with a table of analytic derivatives for elementary functions. Despite reliance on analytic derivatives, it does not compute the analytic derivative of the function–it just computes the _value_ of the derivative for some particular input. In order to differentiate native functions you have to accept a fairly loose definition of "derivative" that basically assumes you can ignore discontinuities in functions. For example, in the function below we can say that the derivative is piecewise continuous with a value of 0 for all x < 0, and value 1 for all x >= 0. AD extends this idea to "each output produced by a function follows a
Read the rest
single path, so the corresponding derivative follows the same path". ``` def f(x): if x >= 0: return x else: return 0 ``` AD cannot magically determine the derivative of `lambda x: exp(x)` or similar–it needs a lookup table for elementary functions, for example: https://github.com/HIPS/autograd/blob/304552b1ba42e42bce97f0... However, AD does support differentiating through program flow control including function calls, loops, conditionals, etc. subject to the caveats above, which is much more difficult to do analytically. The idea has now been generalized to all linear operators in functional programming https://www.youtube.com/watch?v=MmkNSsGAZhw&feature=youtu.be and the associated paper https://dl.acm.org/citation.cfm?doid=3243631.3236765
In JAX: Numpy with Gradients, GPUs and TPUs
Actually, advanced autodiff is one of its intended points of, er, differentiation :). The authors wrote the original Autograd package [0], released in 2014, that led to “autograd” becoming used as a generic term in PyTorch and other packages. JAX has all of the autodiff operations that Autograd does, including `grad`, `vjp`, `jvp`, etc. We’re working on the number of supported NumPy ops, which is limited right now, but it’s early days. Try it out, we’re really excited to see what you build with it! 0: https://github.com/hips/autograd
In JAX: Numpy with Gradients, GPUs and TPUs
> there's nothing in the language that prevents this from working with the autograd package, except no one's taken the time to implement it (https://github.com/HIPS/autograd/issues/47). I believe it's more complicated than most posters there realize, especially in the context of PyTorch (which uses a fork of autograd under the hood) with its dynamic graphs... Anyway, AD deserves its own discussion, that's I didn't want to concentrate on it. > I'd be interested in a side by side comparison as well, and I was thinking that the main difficulty would be that I couldn't write good Julia code, but maybe we can pair up, if that'd be interesting, to address several common topics that come up (fusion, broadcasting, generics but specialization, etc). Sounds good! Do you have a task at hand that would involve all the topics and could be implemented
Read the rest
in limited time? Maybe some kind of Monte Carlo simulation or Gibbs sampling to get started?
In Julia 1.0
> In Julia I follow the following steps: … does it fit with AST? I'm fairly certain the steps you've listed can be accomplished through AST manipulations, and would go something like def manip_ast(fn): import ast, inspect fn_ast = ast.parse(inspect.getsource(fn)) new_fn_ast = … return compile(new_fn_ast, …) def rewrite(fn): fn = manip_ast(fn) fn = numba.jit(fn) @rewrite def func(*args): … there's nothing in the language that prevents this from working with the autograd package, except no one's taken the time to implement it (https://github.com/HIPS/autograd/issues/47). That said, for many tasks with wide vector data, a DL framework is going to do ok, e.g. PyTorch. > Julia compiler / LLVM then generates code that reads and writes to memory exactly once (unlike e.g.
Read the rest
what you would get with several separate operations on numpy arrays) Numba's gufuncs address exactly this + broadcasting over arbitrary input shapes. I've used this extensively. That said, I don't find fusing broadcasting is always a win, especially when arrays exceed cache size. Numba's CUDA support will also fuse jit functions into a single kernel, or generate device functions. Sometimes you want manual control over kernel fusion, and I've found the Loopy (https://documen.tician.de/loopy/) to be fairly flexible in this regard, but it's a completely different approach compared to Numba/Julia. I'd be interested in a side by side comparison as well, and I was thinking that the main difficulty would be that I couldn't write good Julia code, but maybe we can pair up, if that'd be interesting, to address several common topics that come up (fusion, broadcasting, generics but specialization, etc).
In Julia 1.0

Showing the 15 most recent of 21 sources. Enable JavaScript to search and browse every indexed mention.

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.