Skip to content

Instantly share code, notes, and snippets.

@scottire
Last active November 30, 2022 09:38
Show Gist options
  • Save scottire/2395b306818f3e520b6725a69c0dd7e4 to your computer and use it in GitHub Desktop.
Save scottire/2395b306818f3e520b6725a69c0dd7e4 to your computer and use it in GitHub Desktop.
Get started tuning hyperparameters with W&B quickly
import wandb
# 1: Define objective/training function
def objective(config):
score = config.x ** 3 + config.y
return score
def main():
wandb.init(project='my-first-sweep')
score = objective(wandb.config)
wandb.log({'score': score})
# 2: Define the search space
sweep_configuration = {
'method': 'random',
'metric': {'goal': 'minimize', 'name': 'score'},
'parameters':
{
'x': {'max': 0.1, 'min': 0.01},
'y': {'values': [1, 3, 7]},
}
}
# 3: Start the sweep
sweep_id = wandb.sweep(sweep=sweep_configuration, project='my-first-sweep')
wandb.agent(sweep_id, function=main, count=10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment