/pyhopper

PyHopper is a hyperparameter optimizer, made specifically for high-dimensional problems arising in machine learning research.

Primary LanguagePythonApache License 2.0Apache-2.0

PyHopper - High-dim hyperparameter tuning made easy

ci_badge Documentation Status pyversion PyPI version downloads

PyHopper is a hyperparameter optimizer, made specifically for high-dimensional problems arising in machine learning research.

pip3 install -U pyhopper

PyHopper is lightweight, rich in features, and requires minimal changes to existing code

import pyhopper

def my_objective(params: dict) -> float:
    model = build_model(params["hidden_size"],...)
    # .... train and evaluate the model
    return val_accuracy

search = pyhopper.Search(
    {
        "hidden_size": pyhopper.int(100,500),
        "dropout_rate": pyhopper.float(0,0.4),
        "opt": pyhopper.choice(["adam","rmsprop","sgd"]),
    }
)
best_params = search.run(my_objective, "maximize", "1h 30min", n_jobs="per-gpu")

Its most important features are

  • 1-line multi GPU parallelization
  • natively NumPy array hyperparameters support
  • highly customizable (e.g. you can directly tune entire torch.Tensor hyperparameters)

Under its hood, PyHopper uses an efficient 2-stage Markov chain Monte Carlo (MCMC) optimization algorithm.

alt

For more info, check out PyHopper's documentation