• Stars
    star
    945
  • Rank 48,368 (Top 1.0 %)
  • Language
    Jupyter Notebook
  • License
    MIT License
  • Created almost 7 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A pedagogical implementation of Autograd

Autodidact: a pedagogical implementation of Autograd

This is a tutorial implementation based on the full version of Autograd.

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
...     y = np.exp(-2.0 * x)
...     return (1.0 - y) / (1.0 + y)
...
>>> grad_tanh = grad(tanh)       # Obtain its gradient function
>>> grad_tanh(1.0)               # Evaluate the gradient at x = 1.0
0.41997434161402603
>>> (tanh(1.0001) - tanh(0.9999)) / 0.0002  # Compare to finite differences
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:

>>> import matplotlib.pyplot as plt
>>> x = np.linspace(-7, 7, 200)
>>> plt.plot(x, tanh(x),
...          x, grad(tanh)(x),                                # first  derivative
...          x, grad(grad(tanh))(x),                          # second derivative
...          x, grad(grad(grad(tanh)))(x),                    # third  derivative
...          x, grad(grad(grad(grad(tanh))))(x),              # fourth derivative
...          x, grad(grad(grad(grad(grad(tanh)))))(x),        # fifth  derivative
...          x, grad(grad(grad(grad(grad(grad(tanh))))))(x))  # sixth  derivative
>>> plt.show()

Autograd was written by Dougal Maclaurin, David Duvenaud and Matt Johnson. See the main page for more information.

More Repositories

1

pyhsmm

Python
548
star
2

svae

code for Structured Variational Autoencoders
Python
349
star
3

pybasicbayes

Python
153
star
4

pyslds

Python
88
star
5

my-oh-my-zsh

Shell
84
star
6

pylds

some tools for gaussian linear dynamical systems
Python
83
star
7

pyhsmm-autoregressive

autoregressive plugin
Python
27
star
8

pyhsmm-factorial

Python
18
star
9

todo-bash

super-simple command-line todo tracking
Shell
13
star
10

ode-diff-notes

Python
12
star
11

py-manipulate

Python
10
star
12

probprog

simple probabilistic programming in Scheme
Scheme
10
star
13

matlab-hsmm

Objective-C
9
star
14

variational_autoencoder

Python
8
star
15

pplham

Python
7
star
16

spectral_clustering

Python
6
star
17

py4sid

subspace identification for linear systems
Python
6
star
18

py-diskmemo

Python
6
star
19

pykalmanfilters

Python
5
star
20

kalman_grads

Python
4
star
21

pyparticlefilters

Python
4
star
22

pyhsmm-collapsedinfinite

Python
4
star
23

config-vim

my .vim
Vim Script
4
star
24

gaussian-hogwild-gibbs

Python
4
star
25

dirichlet-truncated-multinomial

Python
4
star
26

information-theory-tutorial

Python
4
star
27

config-fish

my fish configuration
Shell
4
star
28

next.ml

JavaScript
3
star
29

yaldapy

yet another LDA implementation
Python
3
star
30

pyhsmm-beamsampling

beam sampling for pyhsmm
Python
3
star
31

pymattutil

a few miscellaneous functions I've found useful
Python
3
star
32

matlab-fftconv

MATLAB
3
star
33

autograd_linalg

improve scipy.linalg and corresponding autograd gradfuns
Python
3
star
34

cs281_linear_regression

Python
2
star
35

mattjj.github.com

2
star
36

cachedproperties

an experiment in property caching
Python
2
star
37

pyhsmm-subhmms

Python
2
star
38

dotfiles

my config files, especially .tmux.conf
Shell
2
star
39

py-stateplots

Python
2
star
40

vim-prefs

my vim prefs, separated so that it can be a bundle
Vim Script
2
star
41

mpi4py-paralleltempering

Python
1
star
42

pykinematics

Python
1
star
43

jsmattutil

JavaScript
1
star