Before you continue, make sure you:
- Configure your training script to create and track hyperparameter combinations with W&B. For more information, see Add W&B to your code.
- Have a configuration file defined for your sweep.
entity: Your W&B username or team name.project: The name of the project where you want W&B to store the output of the run. If the project is not specified, W&B puts the run in a project called “Uncategorized”.sweep_ID: The pseudo random, unique ID generated by W&B.
- CLI
- Python script or notebook
Use the For graceful shutdown when you interrupt the agent (for example, with Ctrl+C), use
wandb agent command to start a sweep. Provide the sweep ID that W&B returns when you initialized the sweep.Copy and paste the code snippet below and replace sweep_id with your sweep ID:wandb agent --forward-signals sweep_id so the current run receives the signal and can shut down cleanly. See Signal handling and sweep runs for details.Limit the number of runs a sweep agent tries
Specify the number of runs a sweep agent should try. The following code snippets demonstrate how to set a maximum number of W&B Runs with the CLI and within a Jupyter Notebook, Python script.- CLI
- Python script or notebook
First, initialize your sweep with the Next, pass an integer value to the count flag to set the maximum number of runs to try.
wandb sweep command. For more information, see Initialize sweeps.