Skip to main content


Run a function or program with configuration parameters specified by server.

sweep_id, function=None, entity=None, project=None, count=None

Generic agent entrypoint, used for CLI or jupyter.

sweep_id(dict) Sweep ID generated by CLI or sweep API
function(func, optional) A function to call instead of the "program" specifed in the config.
entity(str, optional) W&B Entity
project(str, optional) W&B Project
count(int, optional) the number of trials to run.


Run a sample sweep over a function:

import wandb

sweep_configuration = {
"name": "my-awesome-sweep",
"metric": {"name": "accuracy", "goal": "maximize"},
"method": "grid",
"parameters": {"a": {"values": [1, 2, 3, 4]}},

def my_train_func():
# read the current value of parameter "a" from wandb.config
a = wandb.config.a

wandb.log({"a": a, "accuracy": a + 1})

sweep_id = wandb.sweep(sweep_configuration)

# run the sweep
wandb.agent(sweep_id, function=my_train_func)
Was this page helpful?๐Ÿ‘๐Ÿ‘Ž