Skip to main content

distgfs

Distributed computing framework for the Global Function Search (GFS) hyperparameter optimizer from the Dlib library. Based on gfsopt.

Provides the following features:

  • Parallel optimization: Run distributed hyperparameter searches via mpi4py.
  • Save and restore progress: Save/restore settings, parameters and optimization progress to/from HDF5 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 Levi's function with as many parallel processes as there are logical cores, and save progress to file.

import math, distgfs

def levi(x, y):
    """
    Levi's function (see https://en.wikipedia.org/wiki/Test_functions_for_optimization).
    Has a global _minimum_ of 0 at x=1, y=1.
    """
    a = math.sin(3. * math.pi * x)**2
    b = (x - 1)**2 * (1 + math.sin(3. * math.pi * y)**2)
    c = (y - 1)**2 * (1 + math.sin(2. * math.pi * y)**2)
    return a + b + c


def obj_fun(pp, pid):
    """ Objective function to be _maximized_ by GFS. """
    x = pp['x']
    y = pp['y']

    res = levi(0.4*x, y)
    print(f"Iter: {pid}\t x:{x}, y:{y}, result:{res}")
    # Since Dlib maximizes, but we want to find the minimum,
    # we negate the result before passing it to the Dlib optimizer.
    return -res

# For this example, we pretend that we want to keep 'y' fixed at 1.0
# while optimizing 'x' in the range -4.5 to 4.5
space = {'x': [-4.5, 4.5]}
problem_parameters = {'y': 1.}
    
# Create an optimizer parameter set
distgfs_params = {'opt_id': 'distgfs_levi',
                  'obj_fun_name': 'obj_fun',
                  'obj_fun_module': 'example_distgfs_levi_file',
                  'problem_parameters': problem_parameters,
                  'space': space,
                  'n_iter': 10,
                  'file_path': 'distgfs.levi.h5',
                  'save': True,
                 }

distgfs.run(distgfs_params, verbose=True)

For additional examples, see examples.

Release files for distgfs 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for distgfs 1.2.0
File Size Uploaded
distgfs-1.2.0.tar.gz 574.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for distgfs 1.2.0
File Interpreter ABI Platform
distgfs-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 598.1 kB

Release files / distgfs-1.2.0.tar.gz

Download URL distgfs-1.2.0.tar.gz
Size 574.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c84d7e0fabbeb9783ba5492b5170b852ac3458c5c5a03b56e3d79bf18cbed504
BLAKE2b-256 checksum
How to use checksums
dbfcddbfb5f66304215e3c8cc34df5fd9d8f3f921c95083b7acb4a879696cbd5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / distgfs-1.2.0-py3-none-any.whl

Download URL distgfs-1.2.0-py3-none-any.whl
Size 23.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eef6789133afe48c45f2f184159e980c78685fc680b4975a10016fcb9d3de1f5
BLAKE2b-256 checksum
How to use checksums
3954091737f73ffab8fe36a21cd89771ba592c914aa37bad0a878a0da18379fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page