[Numpy-discussion] [ANN] ALGOPY 0.21, algorithmic differentiation in Python

Sebastian Walter sebastian.walter@gmail....
Mon Aug 2 01:20:51 CDT 2010


On Mon, Aug 2, 2010 at 12:16 AM, John Salvatier
<jsalvati@u.washington.edu> wrote:
> Holy cow! I was looking for this exact package for extending pymc! Now I've
> found two packages that do basically exactly what I want (Theano and
> ALGOPY).
>
> Does ALYGOPY handle derivatives of operations on higher order ndimensional
> arrays well (efficiently and including broadcasting and such)?


Yes, no problem.

operations on multidimensional arrays:
--------------------------------------------------------

In [6]: import numpy

In [7]: import algopy

In [8]: x = algopy.UTPM(numpy.ones((2,1,2,3,4,5,6)))

In [9]: x.shape
Out[9]: (2, 3, 4, 5, 6)

In [10]: x.data.shape
Out[10]: (2, 1, 2, 3, 4, 5, 6)

In [11]: y = numpy.sin(x)

In [12]: y.shape
Out[12]: (2, 3, 4, 5, 6)

In [13]: y.data.shape
Out[13]: (2, 1, 2, 3, 4, 5, 6)


broadcasting
-------------------

In [14]: z = algopy.UTPM(numpy.ones((2,1,4,1,6)))

In [15]: y = x*z

In [16]: z.shape
Out[16]: (4, 1, 6)

In [17]: y.shape
Out[17]: (2, 3, 4, 5, 6)


Sebastian


>
> John
>
> On Sun, Aug 1, 2010 at 5:05 AM, Sebastian Walter
> <sebastian.walter@gmail.com> wrote:
>>
>> I'm happy to announce the first official release of ALGOPY in version
>> 0.2.1.
>>
>> Rationale:
>> ~~~~~~~~
>> The purpose of ALGOPY is the evaluation of higher-order derivatives in
>> the forward and reverse mode of Algorithmic Differentiation (AD) using
>> univariate Taylor polynomial arithmetic. Particular focus are
>> functions that contain numerical linear algebra functions (e.g. inv,
>> dot, eigh, qr, cholesky,...) as they often appear in statistically
>> motivated functions.
>>
>> Download:
>> ~~~~~~~~~
>> http://pypi.python.org/pypi/algopy/0.2.1
>> or bleeding edge versions from from http://github.com/b45ch1/algopy
>>
>> Documentation:
>> ~~~~~~~~~~~~
>> available at http://packages.python.org/algopy/
>>
>> OS Support:
>> ~~~~~~~~~~
>> Linux, Windows (tested with pythonxy), should also work on Mac
>>
>> Software Dependencies:
>> ~~~~~~~~~~~~~~~~~~~~
>> for the core: numpy, scipy
>> for testing:  nose
>>
>> Exampe Session:
>> ~~~~~~~~~~~~~
>> Consider the contrived example where it is the goal to compute the
>> directional derivative df/dx_1 :
>>
>> >>> import numpy; from numpy import log, exp, sin, cos
>> >>> import algopy; from algopy import UTPM, dot, inv, zeros
>> >>>
>> >>> def f(x):
>> ...     A = zeros((2,2),dtype=x)
>> ...     A[0,0] = numpy.log(x[0]*x[1])
>> ...     A[0,1] = numpy.log(x[1]) + exp(x[0])
>> ...     A[1,0] = sin(x[1])**2 + cos(x[0])**3.1
>> ...     A[1,1] = x[0]**cos(x[1])
>> ...     return log( dot(x.T,  dot( inv(A), x)))
>> ...
>> >>>
>> >>> x = UTPM(zeros((2,1,2),dtype=float))
>> >>> x.data[0,0] = [1,2]
>> >>> x.data[1,0] = [1,0]
>> >>> y = f(x)
>> >>>
>> >>> print 'normal function evaluation f(x) = ',y.data[0,0]
>> normal function evaluation f(x) =  0.641250189986
>> >>> print 'directional derivative df/dx1 = ',y.data[1,0]
>> directional derivative df/dx1 =  1.62982340133
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion@scipy.org
>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>


More information about the NumPy-Discussion mailing list