Giter Club home page Giter Club logo

autodiff's Introduction

AppVeyor CI NuGet Package
Build Status NuGet

Project Description

A library that provides moderately fast, accurate, and automatic differentiation (computes derivative / gradient) of mathematical functions.

AutoDiff provides a simple and intuitive API for computing function gradients/derivatives along with a fast algorithm for performing the computation. Such computations are mainly useful in iterative numerical optimization scenarios.

Code example

using AutoDiff;

class Program
{
    public static void Main(string[] args)
    {
            // define variables
            var x = new Variable();
            var y = new Variable();
            var z = new Variable();
    
            // define our function
            var func = (x + y) * TermBuilder.Exp(z + x * y);
    
            // prepare arrays needed for evaluation/differentiation
            Variable[] vars = { x, y, z };
            double[] values = {1, 2, -3 };
    
            // evaluate func at (1, 2, -3)
            double value = func.Evaluate(vars, values);
    
            // calculate the gradient at (1, 2, -3)
            double[] gradient = func.Differentiate(vars, values);
    
            // print results
            Console.WriteLine("The value at (1, 2, -3) is " + value);
            Console.WriteLine("The gradient at (1, 2, -3) is ({0}, {1}, {2})", gradient[0], gradient[1], gradient[2]);
    }
}

Documentation

The Documentation contains some basic tutorials, we have an article on CodeProject, and finally source code contains some code examples in addition to the code of the library itself.

Motivation

There are many open and commercial .NET libraries that have numeric optimization as one of their features (for example, Microsoft Solver Foundation, AlgLib,Extreme Optimization, CenterSpace NMath) . Most of them require the user to be able to evaluate the function and the function's gradient. This library tries to save the work in manually developing the function's gradient and coding it. Once the developer defines his/her function, the AutoDiff library can automatically evaluate and differentiate this function at any point. This allows easy development and prototyping of applications which require numerical optimization.

Features

  • Moderate execution speeds. We aim computing a gradient within no more than 50 times the duration of function evaluation by manually tuned code.
  • Composition of functions using arithmetic operators, Exp, Log, Power and user-defined unary and binary functions.
  • Function gradient evaluation at specified points
  • Function value evaluation at specified points
  • Computes gradients using Reverse-Mode AD algorithm in linear time, which is substantially faster than numerical gradient approximation for multivariate functions.

Using in research papers

If you like the library and it helps you publish a research paper, please cite the paper I originally wrote the library for geosemantic.bib

Used by

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.