Scaffolding for the Global Function Search optimizer from Dlib
Project description
gfsopt
pip3 install --user gfsopt
Convenient scaffolding for the excellent Global Function Search hyperparameter optimizer from the Dlib library. (See: 'A Global Optimization Algorithm Worth Using')
Provides the following features:
- Parallel optimization: Run multiple hyperparameter searches in parallel
- Save and restore progress: Save/restore settings 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.
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} # 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file gfsopt-1.1.0.tar.gz
.
File metadata
- Download URL: gfsopt-1.1.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 938e77d6b9abf730ede62ebc99559fb13f5080c5700f48a0451809d1f83eee43 |
|
MD5 | 3f6a442c04ac0b1aa4e0f32f61e2d117 |
|
BLAKE2b-256 | 03fefc6f0d1d0a20bc35bdbbc0375b1de6c11c67f90e5d0c37fea4d34240e860 |
File details
Details for the file gfsopt-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: gfsopt-1.1.0-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7db053cd485de8d31448477c9b3352a243271aefa4e4a3394a8f39be97055ad4 |
|
MD5 | 7dfc39da97e3cdcaa87d6b583a1f7f5f |
|
BLAKE2b-256 | 19e1eaef8f66dc93600a6319a0c72cb21baa2687b99b840a42b77496216451de |