Giter Site home page Giter Site logo

autodiff's Introduction

AutoDiff - A framework for doing automatical differentiation

Basic Usage

The framework works around the AdFloat object. To evaluate a function for a value, you need to create this value as an AdFloat

from autodiff import AdFloat
x = AdFloat(27)

simple operations like + - * / is overloaded, so you can just do

f = lambda x: x*2 
value = f(x)

value is now an AdFloat, which means that you can access both the derivative, and the evaluated value by

print(value.dx)
> 2
print(value.x)
> 52

For more complex functions, you have to import the implemented versions.

from autodiff import AdFloat, sin
x = AdFloat(3.14159265)
f = lambda x: sin(x)
value = f(x)
print(value.dx)
> -1

Chaining derivatives

The power of automatic differentiation comes from the fact, that one can evaluate derivatives of arbitrary functions without nummeric approximations.
To work with functions with multiple terms, simply write them as normal

from autodiff import AdFloat, sin, exp
x = AdFloat(1)
f = lambda x: sin(exp(x*4)) + (x+2)**2
print(f(x).dx)
> -74.94977972639266 

Installation

Windows

WINDOWS
AutoDiff is available as a precompiled wheel for windows, and can be installed using

pip install autodiff

Other platforms

For other platforms it can be build from source by downloading the repository, and running
python setup.py install

This requires that you have installed a c compiler

autodiff's People

Contributors

jeppe742 avatar

Watchers

James Cloos avatar  avatar

autodiff's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.