-
Notifications
You must be signed in to change notification settings - Fork 14
Home
b45ch1 edited this page Sep 13, 2010
·
52 revisions
ALGOPY is a Python module for automatic differentiation of algorithms written in Python.
The project is at an early alpha stage and is likely to change. The name derives from ALGOrithmic differentiation of PYthon programs.
Algorithmic differentiation also known as automatic differentiation or simply AD.
Current Main Features
- Full support for Numpy functions: numpy.exp(), numpy.sin(), numpy.dot(), numpy.outer() etc.
- Works on scalars and on matrices
- scalars: arbitrary order
- matrices: second order
- Saves the computational graph in a vertex list and natively supports plotting of the computational graph with graphviz
Intermediate Goals
- Performance comparable to ADOL-C in the scalar case (about 10 times slower or so)
- Outperforming ADOL-C on matrix operations when matrices are sufficiently large. Current performance can be checked here
- Arbitrary order derivatives of matrix operations
- Connect the Scalar derivative evaluation with the Matrix derivative evaluation (i.e. share the same computational graph).
- Easy to use drivers for matrix operations (hessian, gradient, jacobian, etc)
- Connecting with PyADOLC and PyCPPAD
Easy Example
An easy example from the unit test. We want to compute the Hessian of the function fun(x):
from numpy import *
from reverse_mode import *
# defining the function
A = array([[11., 3.],[3.,17.]])
def fun(x):
return 0.5* dot(x, dot(A,x))
# compute the Hessian
x = array([3.,7.])
H = hessian(fun,x)
print 'H=',H
assert prod(H == A)
#----------------------------------------------
# OUTPUT:
# H=[[11.,3.],
# 3.,17.]]
We aim for full Numpy support, i.e. all algorithms that use elementary Python types (lists, floats) and numpy arrays and array operations as numpy.dot should work out of the box. Numpy.dot already works flawlessly.
Software Dependencies
- For arrays/matrices we use Numpy.
- For some of the examples and unit tests you will need the python wrapper of ADOL-C (PyADOLC). It will be released early 2009 to the public.
- For the unit tests we use py.test
- To plot the graphs we use pygraphviz/graphviz
Under Debian based systems you can get everything you need by:
sudo apt-get install python ipython python-numpy python-matplotlib graphviz python-pygraphviz