How to use list as a parameter for sweeps

A simplified example of my sweep config looks like the following.

sweep_config = {
    "method": "random",
    "metric": {"name": "val.loss", "goal": "minimize"},
    "parameters": {
               "lims": {"value": [[1,28], [1,28]]},
               "size": {"value": [28, 28]},
               "num_channels": {"value": 3}
            }
}

What I want to do is to pass [[1,28], [1,28]] and [28, 28] as a fixed arguments to the parameters lims and size during the sweep process, so that the model receives lims=[[1,28], [1,28]] and size=[28, 28]. However, it seems that sweep only allows scalar values to be passed as fixed arguments(like the case of num_channels) and not lists. How can I use lists as arguments to sweep?

Hey @hlee2745, thanks for your question! You should be able to pass a list as a sweep param with a code like:

import wandb

def train_model(config=None):
    # This function simulates training a model with given parameters.
    # Replace this with your actual model training code.
    with wandb.init(config=config):
        config = wandb.config
        print(f"Training model with lims={config.lims}, size={config.size}, num_channels={config.num_channels}")
        # Here, you would have your model training logic.
        # For this example, we're just printing the parameters.

sweep_config = {
    "method": "random",  # Example method, adjust based on your sweep strategy
    "metric": {"name": "val.loss", "goal": "minimize"},
    "parameters": {
        "lims": {"value": [[1,28], [1,28]]},  # Fixed argument
        "size": {"value": [28, 28]},          # Fixed argument
        "num_channels": {"value": 3}          # Fixed argument, but as a scalar
    }
}

sweep_id = wandb.sweep(sweep_config, project="test_sweeps_list")
wandb.agent(sweep_id, train_model)

Thanks for the reply:) I tried the same thing before but it didn’t work and that’s why I asked the question but it seems to work now.

That’s great to hear! Will then mark this as resolved