Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
A

autograd

> DevOps
Open source

Efficiently computes derivatives of NumPy code.

7.5K stars0 likes1 views
WebsiteGitHub

About

Efficiently computes derivatives of NumPy code.

Autograd Checks status Tests status Publish status asv

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:

python
>>> 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:

python
>>> 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:

bash
pip install autograd

Some features require SciPy, which you can install separately or as an optional dependency along with Autograd:

bash
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.

Issues· 192 open

View all issuesOpen on GitHub
  • #555

    copy.deepcopy leads to incorrect gradient

    Updated Aug 31, 2026
  • #630

    Implement better testing and against multiple NumPy versions

    Updated Aug 31, 2026
  • #802

    Gradient of where() is sometimes erroneously NaN when the inactive case is NaN

    Updated Aug 30, 2026
  • #788

    Gaps in NumPy API coverage: unwrapped subpackages and missing gradients

    Updated Jul 8, 2026
  • #644

    Add Support for `numpy.convolve()`

    PR welcomeUpdated Jun 16, 2026
  • #623

    Support numpy.mgrid

    PR welcomeUpdated Jun 16, 2026
  • #551

    np.issubdtype(np.int32, np.integer) fails

    Updated Apr 25, 2026
  • #752

    Convenience: cbrt and atan2.

    Updated Jan 15, 2026
  • #47

    Numba support

    enhancementUpdated Dec 15, 2025
  • #743

    support numpy.take

    PR welcomegood first issueUpdated Nov 25, 2025

> Tags

Pythonautogradautomatic-differentiationbackpropagationdeep-learning

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 2, 2026
CategoryDevOps
PricingOpen source

> Related tools

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理