Giter Site home page Giter Site logo

hydra-wandb-sweeper's Introduction

WandB sweeper integration with Hydra

Installing

$ pip install git+https://github.com/captain-pool/hydra-wandb-sweeper.git

Usage

Using this plugin is very simple, as one can just invoke the sweeper by overriding hydra/sweeper with wandb.

@hydra.main(config_path=..., config_name=...)
def main(cfg: DictConfig):

  with wandb.init(id=run_id) as run:
    ...
    wandb.log({"loss": loss})

Hydra Overrides

Passing Distributions for continuous parameters

Sweeping over continuous params (for ex. learning rates in ML pipelines) can be done by passing the upper limit and lower with the hydra's interval(<min>, <max>) override. For example:

$ python3 /path/to/trainer/file hydra/sweeper=wandb model.learning_rate="interval(0.1, 0.2)"

By default, the interval() sweep uses the uniform distribution while making parameter suggestions. To use a different distribution add the name of the supported distribution (uniform, log_uniform, q_uniform, q_log_uniform, q_normal, log_normal, q_log_normal) as a tag to the interval() sweep. For example, to use a normal distribution with mean=0 and variance=1 to suggest a value for learning_rate use the following:

$ python3 /path/to/trainer/file hydra/sweeper=wandb model.learning_rate="tag(normal, interval(0, 1))"

Categorial parameters

Sweeping over categorical items is as simple as passing a list of items to sweep over thereby directly using Hydra' choice() sweep feature. for example, to sweep over a categorical list of batch_size,

$ python3 /path/to/trainer/file hydra/sweeper=wandb model.batch_size=8,10,12,14

Equivalently, the choice() command can also be expliclty used:

$python3 /path/to/trainer/file hydra/sweep=wandb model.batch_size="choice(8,10,12,14)".

Categorical sweep can also be done using hydra's range() sweep. The previous task can be equivalently achieved as:

$ python3 /path/to/trainer/file hydra/sweeper=wandb model.batch_size="range(8, 15, step=2)"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.