Volver al ranking

HIPS/autograd

Python

Efficiently computes derivatives of NumPy code.

autogradautomatic-differentiationnumpypythondeep-learningderivativejaxmachine-learningneural-networknumpy-arraysscipyufunc
Crecimiento de estrellas
Estrellas
7.5k
Forks
936
Crecimiento semanal
Issues
159
2k4k6k
nov 2014sept 2018ago 2022jul 2026
ArtefactosPyPIpip install autograd
README

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:

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

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.

Repositorios relacionados
pytorch/pytorch

Tensors and Dynamic neural networks in Python with strong GPU acceleration

PythonPyPIOtherneural-networkautograd
pytorch.org
101.8k28.4k
chenyuntc/pytorch-book

PyTorch tutorials and fun projects including neural talk, neural style, poem writing, anime generation (《深度学习框架PyTorch:入门与实战》)

Jupyter NotebookMIT Licensepytorchpytorch-tutorials
12.8k3.7k
flashlight/flashlight

A C++ standalone library for machine learning

C++MIT Licenseflashlightmachine-learning
fl.readthedocs.io/en/latest/
5.4k500
BoltzmannEntropy/interviews.ai

It is my belief that you, the postgraduate students and job-seekers for whom the book is primarily meant will benefit from reading it; however, it is my hope that even the most experienced researchers will find it fascinating as well.

data-sciencemachine-learning
interviews.ai
4.9k325
deepjavalibrary/djl

An Engine-Agnostic Deep Learning Framework in Java

JavaMavenApache License 2.0deep-learningneural-network
djl.ai
4.8k752
MegEngine/MegEngine

MegEngine 是一个快速、可拓展、易于使用且支持自动求导的深度学习框架

C++Apache License 2.0deep-learningmachine-learning
megengine.org.cn
4.8k549
PennyLaneAI/pennylane

PennyLane is an open-source quantum software platform for quantum computing, quantum machine learning, and quantum chemistry. Create meaningful quantum algorithms, from inspiration to implementation.

PythonPyPIApache License 2.0quantummachine-learning
pennylane.ai
3.4k840
n2cholas/awesome-jax

JAX - A curated list of resources https://github.com/google/jax

Creative Commons Zero v1.0 Universalawesomeawesome-list
2.1k170
prabhuomkar/pytorch-cpp

C++ Implementation of PyTorch Tutorials for Everyone

C++MIT Licensecplusplusartificial-intelligence
2.1k274
chelsea0x3b/dfdx

Deep learning in Rust, with shape checked tensors and neural networks

Rustcrates.ioOtherrustautograd
1.9k107
coreylowman/dfdx

Deep learning in Rust, with shape checked tensors and neural networks

Rustcrates.ioOtherrustautograd
1.8k106
mratsim/Arraymancer

A fast, ergonomic and portable tensor library in Nim with a deep learning focus for CPU, GPU and embedded devices via OpenMP, Cuda and OpenCL backends

NimApache License 2.0tensornim
mratsim.github.io/Arraymancer/
1.4k101