Skip to main content
Access hyperparameter names and values from the sweep configuration using (run.config()), which acts like a dictionary. For runs outside a sweep, set wandb.Run.config() values by passing a dictionary to the config argument in wandb.init(). In a sweep, any configuration supplied to wandb.init() serves as a default value, which the sweep can override. Use rwandb.Run.config.setdefaults() for explicit behavior. The following code snippets illustrate both methods:
# Set default values for hyperparameters
config_defaults = {"lr": 0.1, "batch_size": 256}

# Start a run and provide defaults
# that a sweep can override
with wandb.init(config=config_defaults) as run:
    # Add training code here
    ...

Sweeps