Skip to main content

List Hydra Sweeper plugin

Project description

List Sweeper plugin for Hydra

Sweeper plugin for Hydra which creates a list option additionally to the cartesian product ("grid"), which allows to sweep over the zipped list of parameters. This allows to test only a subset of the cartesian product and it is useful for small hyperparameter searches.

Installation

Clone this repository, navigate to its root folder hydra_list_sweeper and run:

pip install .

This will install the plugin in your current environment. Right now, there is no way to install it from PyPi, but this will be added in the future.

You can check if the plugin is installed by adding --info plugins to your command line. The plugin should be listed in the output as hydra_plugins.list_sweeper_plugin.list_sweeper.

In order to enable this plugin, you need to override the default sweeper in your configuration file:

defaults:
  - _self_
  # override this to use the new list sweeper:
  - override hydra/sweeper: list

Usage

List sweeper uses the a similar syntax as the standard sweeper, but instead of a params key, it uses grid_params and list_params:

hydra:
  mode: MULTIRUN
  sweeper:
    # standard grid search
    grid_params:
      env: 5_clubs_juggling, balancing_stick
    # additional list sweeper
    list_params:
      algorithm.lr: 0.001, 0.0001
      algorithm.beta_1: [0.9, 0.99]  # both notations work

This configuration will create 4 jobs:

env=5_clubs_juggling, algorithm.lr=0.001, algorithm.beta_1=0.9
env=5_clubs_juggling, algorithm.lr=0.0001, algorithm.beta_1=0.99
env=balancing_stick, algorithm.lr=0.001, algorithm.beta_1=0.9
env=balancing_stick, algorithm.lr=0.0001, algorithm.beta_1=0.99

Basically, it grids over all grid params, creating the standard cartesian product, and then for each of these combinations, it creates a job for each of the list params. You can additionally overwrite single values with command line arguments, and even define your grid_params in the command line:

hydra:
  mode: MULTIRUN
  sweeper:
    # additional list sweeper
    list_params:
      algorithm.lr: 0.001, 0.0001
      algorithm.beta_1: [0.9, 0.99]  # both notations work

Combined with this command

python my_app.py env=5_clubs_juggling,balancing_stick

will produce the same results as the first example. Also, you can override configs with the command line and the grid_params:

hydra:
  mode: MULTIRUN
  sweeper:
    # standard grid search
    grid_params:
      env: 5_clubs_juggling, balancing_stick
    # additional list sweeper
    list_params:
      algorithm.lr: 0.001, 0.0001
      algorithm.beta_1: [0.9, 0.99]  # both notations work

Combined with this command:

python my_app.py algorithm.epsilon=1.0e-4

will produce the same results as the first example, but epsilon will be set to 1.0e-4 for all jobs.

If you remove the list_params section, it will behave exactly as the standard grid sweeper (at least it should do, if you find a bug, please report it).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hydra-list-sweeper-1.0.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hydra_list_sweeper-1.0.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file hydra-list-sweeper-1.0.0.tar.gz.

File metadata

  • Download URL: hydra-list-sweeper-1.0.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.7

File hashes

Hashes for hydra-list-sweeper-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1ad96007591c23ce81a23aee91f92defee726cb99c5c4d20ea15a7398a033928
MD5 74baca3689e2124e6281e00c508438be
BLAKE2b-256 397f88704325890e6b6b239d33eedd389d75fb271cde645e5606a05bf2012fff

See more details on using hashes here.

File details

Details for the file hydra_list_sweeper-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hydra_list_sweeper-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dfc22e346998d9be528db9c5600f6cbaa84f6e76f4f3e8cd7636a11ceb16d62e
MD5 f791269ebd1e48829111c1aea1cad13f
BLAKE2b-256 8fdf1dd8b2c8d319eb59e74006b3ea32566e2e7e18621883fa551b5852ef133d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page