Documentation
Search…
wandb.config
Config object
1
config() -> None
Copied!
Config objects are intended to hold all of the hyperparameters associated with a wandb run and are saved with the run object when wandb.init is called.
We recommend setting wandb.config once at the top of your training experiment or setting the config as a parameter to init, ie. wandb.init(config=my_config_dict)
You can create a file called config-defaults.yaml, and it will automatically be loaded into wandb.config. See https://docs.wandb.com/library/config#file-based-configs.
You can also load a config YAML file with your custom name and pass the filename into wandb.init(config="special_config.yaml"). See https://docs.wandb.com/library/config#file-based-configs.

Examples:

Basic usage
1
wandb.config.epochs = 4
2
wandb.init()
3
for x in range(wandb.config.epochs):
4
# train
Copied!
Using wandb.init to set config
1
wandb.init(config={"epochs": 4, "batch_size": 32})
2
for x in range(wandb.config.epochs):
3
# train
Copied!
Nested configs
1
wandb.config['train']['epochs] = 4
2
wandb.init()
3
for x in range(wandb.config['train']['epochs']):
4
# train
Copied!
Using absl flags
1
flags.DEFINE_string(‘model’, None, ‘model to run’) # name, default, help
2
wandb.config.update(flags.FLAGS) # adds all absl flags to config
Copied!
Argparse flags
1
wandb.init()
2
wandb.config.epochs = 4
3
4
parser = argparse.ArgumentParser()
5
parser.add_argument('-b', '--batch-size', type=int, default=8, metavar='N',
6
help='input batch size for training (default: 8)')
7
args = parser.parse_args()
8
wandb.config.update(args)
Copied!
Using TensorFlow flags (deprecated in tensorflow v2)
1
flags = tf.app.flags
2
flags.DEFINE_string('data_dir', '/tmp/data')
3
flags.DEFINE_integer('batch_size', 128, 'Batch size.')
4
wandb.config.update(flags.FLAGS) # adds all of the tensorflow flags to config
Copied!
Last modified 10h ago
Copy link