Skip to main content
Initialize and manage W&B runs to organize your experiments and track your work.

Create an experiment

"""
Create an experiment in W&B. If the project does not exist, W&B creates it.

Note that this file only initializes the experiment; you can add code to log metrics,
artifacts, etc., within the `with` block.
"""
import wandb

# Initialize a W&B run
with wandb.init(project="<project>") as run:
    # Experiment code goes here
    pass

Fork an existing run from a specific step

"""Fork an existing W&B run from a specific step."""

import wandb

# Initialize a run to be forked later
with wandb.init(project="<project>", entity="<entity>") as original_run:
    # Training and logging code goes here.
    pass

# Fork the run from a specific step
with wandb.init(project="<project>",entity="<entity>", fork_from=f"{original_run.id}?_step=200") as forked_run:
    # Training and logging code goes here.
    pass

Initialize a run

"""
Initializes a W&B run.

W&B automatically creates the project if it does not exist. Note that this
file only initializes the experiment; you can add code to log metrics,
artifacts, etc., within the `with` block.
"""
import wandb

# Note the usage of `with` statement to ensure proper resource management.
with wandb.init(project="<project>") as run:
    # Training and logging code goes here
    pass