🐝

【ML】Wandb hyperparameter manegement

2024/08/08に公開

I explained about the Wandb in another article. This time explain how to manage hyperparameter in wandb.

1. Hyperparameters

We can track the parameters like this:

import wandb

# Define a config dictionary object
config = {
    "hidden_layer_sizes": [32, 64],
    "kernel_sizes": [3],
    "activation": "ReLU",
    "pool_sizes": [2],
    "dropout": 0.5,
    "num_classes": 10,
}

# Pass the config dictionary when you initialize W&B
run = wandb.init(project="config_example", config=config)
# Access values with the key as the index value
hidden_layer_sizes = wandb.config["hidden_layer_sizes"]
kernel_sizes = wandb.config["kernel_sizes"]
activation = wandb.config["activation"]

# Python dictionary get() method
hidden_layer_sizes = wandb.config.get("hidden_layer_sizes")
kernel_sizes = wandb.config.get("kernel_sizes")
activation = wandb.config.get("activation")

・The Results
We can check the tracking value with run tab on wandb site. (For this image, use a different code from the above example code. The values registered in config are shown run tab.)

I managed parameters with txt file, but it is so useful. This can also filter the most useful columns by the experiments before.
It's very easy and I recommend you try it.

Reference

[1] wandb, configure experiments

Discussion