GitXplorerGitXplorer
t

gfsopt

public
14 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
b56d3130928912f855d9234c376dbdca0d4d6d29

Improve documentation, begin add typing, simplify and clarify code

ttsoernes committed 9 months ago
Unverified
6c4f5f1c22a80dbeffd04330b22ed91c132e17a0

Remove done TODO

ttsoernes committed 6 years ago
Unverified
f4c3fe2ae024a04ab6a33b5d4fb06a51724a6813

Merge remote-tracking branch 'origin/master'

ttsoernes committed 6 years ago
Unverified
a7308340656f4f19f8739d78c5a2c1943f1b99ed

Bump version to 1.1.0

ttsoernes committed 6 years ago
Unverified
1f867026a6d79b4c1571265720e5c2d35dc4fa54

Do not save by default

ttsoernes committed 6 years ago
Unverified
dba1dd3aa244d0ce436dd71bad7b22d253408f77

Workarund bug where Dlib reports nan as best result

ttsoernes committed 6 years ago

README

The README file for this repository.

gfsopt

Documentation Status Latest Version

pip3 install --user gfsopt

Convenient scaffolding for the excellent Global Function Search (GFS) hyperparameter optimizer from the Dlib library.

Provides the following features:

  • Parallel optimization: Run multiple hyperparameter searches in parallel on multiple cores
  • Save and restore progress: Save/restore settings, parameters and optimization progress to/from file.
  • Average over multiple runs: Run a stochastic objective function using the same parameters multiple times and report the average to Dlib's Global Function Search. Useful in highly stochastic domains to avoid biasing the search towards lucky runs.

For theoretical background of GFS, see 'A Global Optimization Algorithm Worth Using' and Malherbe & Vayatis 2017: Global optimization of Lipschitz functions

Example usage

A basic example where we maximize obj_func with respect to y over 10 runs, with as many parallel processes as there are logical cores, and save progress to file.

from gfsopt import GFSOptimizer

def obj_func(x, y, pid):
    """"Function to be maximized (pid is iteration number)""""
    a = (1.5 - x + x * y)**2
    b = (2.25 - x + x * y * y)**2
    c = (2.625 - x + x * y * y * y)**2
    return -(a + b + c)
    
# For this example, we pretend that we want to keep 'x' fixed at 0.5
# while optimizing 'y' in the range -4.5 to 4.5
pp = {'x': 0.5}  # Fixed problem parameters
space = {'y': [-4.5, 4.5]}  # Parameters to optimize over
optimizer = GFSOptimizer(pp, space, fname="test.pkl")
# Will sample and test 'y' 10 times, then save results, progress and settings to file
optimizer.run(obj_func, n_sims=10)

For a more extensive example, see example.py.

Installation & Requirements

Requires Python >=3.6 and the following libraries:

datadiff
dlib
numpy

To install, do:

pip3 install --user gfsopt

Documentation

See example.py for an example and http://gfsopt.readthedocs.io/ for API documentation.