Skip to main content

Optimization with autodiff

Project description

# autoptim: automatic differentiation + optimization

Do you have a new machine learning model that you want to optimize, and do not want to bother computing the gradients? Autoptim is for you.

## Short presentation
Autoptim is a small Python package that blends `autograd` automatic differentiation in `scipy.optimize.minimize`.

The gradients are computed under the hood using automatic differentiation; the user only provides the objective function:

import numpy as np
from autoptim import minimize

def rosenbrock(x):
return (1 - x[0]) ** 2 + 100 * (x[1] - x[0] ** 2) ** 2

x0 = np.zeros(2)

x_min, _ = minimize(rosenbrock, x0)

>>> [0.99999913 0.99999825]

It comes with the following features:

- **Natural interfacing with Numpy**: The objective function is written in standard Numpy. The input/ output of `autoptim.minimize` are Numpy arrays.

- **Smart input processing**: `scipy.optimize.minimize` is only meant to deal with one-dimensional arrays as input. In `autoptim`, variables can be multi-dimensional arrays or lists of arrays.
- **Preconditioning**: Preconditioning is a simple way to accelerate minimization, by doing a change of variables. `autoptim` makes preconditioning straightforward.

### Disclaimer

This package is meant to be as easy to use as possible. As so, some compromises on the speed of minimization are made.
## Installation
To install, use `pip`:
pip install autoptim
## Dependencies
- numpy>=1.12
- scipy>=0.18.0
- autograd >= 1.2

## Examples
Several examples can be found in `autoptim/tutorials`

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for autoptim, version 0.3
Filename, size File type Python version Upload date Hashes
Filename, size autoptim-0.3-py3-none-any.whl (5.7 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page