How to log folding correctly

Hello, I am new to wandb so I tried to explore different methods in which I can log my foldings. I need to do a 10-fold validation, so in order to collect data during each fold, I created a run for each fold and grouped them under the same name. I am not sure that I am doing it the correct way, so I would be grateful if somebody could recommend me other methods.
I attached an example of what I already did.

hey @razvanip - this is certainly one way you could go about this. I’ll propose a few other methods as well depending on what would work better for your workflow:

Single Run with Tags for Each Fold

You can create a single run and use tags to differentiate between the different folds. This way, all the data is in one place, and you can filter by tags in the W&B dashboard to see results for each fold.

import wandb

# Initialize a single W&B run
run = wandb.init(project="your_project_name", name="10_fold_validation")

for fold in range(10):
    # Use tags to differentiate between folds
    wandb.run.tags = [f"fold_{fold}"]

    # Your training code here

    # Log metrics for the fold
    wandb.log({"accuracy": accuracy, "loss": loss, "fold": fold})

# Finish the run after all folds are completed
wandb.finish()

Grouping Runs

If you prefer to have separate runs for each fold, you can group them together using the group parameter when initializing the run. This allows you to filter and compare runs within the same group in the W&B dashboard.

import wandb

for fold in range(10):
    # Initialize a W&B run for each fold and group them
    run = wandb.init(project="your_project_name", group="10_fold_validation", name=f"fold_{fold}")

    # Your training code here

    # Log metrics for the fold
    wandb.log({"accuracy": accuracy, "loss": loss})

    # Finish the run for the current fold
    wandb.finish()
1 Like

Hi @razvanip, since we have not heard back from you we are going to close this request. If you would like to re-open the conversation, please let us know!