Code Monkey home page Code Monkey logo

zoopt's Introduction

ZOOpt

license

A python package of Zeroth-Order Optimization (ZOOpt).

Zeroth-order optimization (a.k.a. derivative-free optimization/black-box optimization) does not rely on the gradient of the objective function, but instead, learns from samples of the search space. It is suitable for optimizing functions that are nondifferentiable, with many local minima, or even unknown but only testable.

Install: pip install zoopt

A quick example

We define the Ackley function for minimization using Theano

import math, theano, theano.tensor as T
x = T.dvector('x')
f = theano.function([x], -20 * T.exp(-0.2 * T.sqrt((T.dot(x - 0.2, x - 0.2)).mean())) - T.exp(
    (T.cos(2 * math.pi * (x - 0.2))).mean()) + math.e + 20)

Ackley function is a classical function with many local minima. In 2-dimension, it looks like (from wikipedia)

Expeirment results

Then, use ZOOpt to optimize a 100-dimension Ackley function

from zoopt import Dimension, Objective, Parameter, Opt, Solution
dim = 100 # dimension
obj = Objective(lambda s: f(s.get_x()), Dimension(dim, [[-1, 1]] * dim, [True] * dim)) # setup objective
# perform optimization
solution = Opt.min(obj, Parameter(budget=100 * dim))
# print result
solution.print_solution()

For a few seconds, the optimization is done. Then, we can visualize the optimization progress

from matplotlib import pyplot
pyplot.plot(obj.get_history_bestsofar())
pyplot.savefig('figure.png')

which looks like

Expeirment results

More examples are available in the example fold.

release 0.1

  • Include the general optimization method RACOS (AAAI'16) and Sequential RACOS (AAAI'17), and the subset selection method POSS (NIPS'15).
  • The algorithm selection is automatic. See examples in the example fold.
  • Default parameters work well on many problems, while parameters are fully controllable
  • Running speed optmized for Python

zoopt's People

Contributors

alexliuyuren avatar paper2019 avatar eyounx avatar

Watchers

James Cloos avatar

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.