Skip to main content
A run is a single unit of computation logged by W&B. You can think of a W&B Run as an atomic element of your whole project. In other words, each run is a record of a specific computation, such as training a model and logging the results, hyperparameter sweeps, and so forth. Common use cases for initializing and logging to a run include: To initialize a W&B run, call the wandb.init() method from the W&B Python SDK. This starts a new run and returns a wandb.Run object that you can use to log metrics, artifacts, and other information to the run. For more information about initializing a run, see Initialize runs. Each run object has a unique identifier known as a run ID. You can specify a unique ID or let W&B randomly generate one for you. Each run object also has a human-readable, non-unique run name. You can specify a name for your run or let W&B randomly generate one for you. You can rename a run after initializing it. W&B logs your run to a project. You specify the project when you initialize the run with wandb.init(project=""). W&B creates a new project if the project does not exist. If the project does exist, W&B logs the run to the project you specified.
If you do not specify a project name, W&B stores the run in a project called Uncategorized.
wandb.init() returns a wandb.Run object that contains properties of the run, such as its ID, name, configuration, and state. Use the run object to log metrics, artifacts, and other information to the run with methods such as wandb.Run.log(), wandb.Run.log_code(), and wandb.Run.use_artifact(). Each run has a state that describes the current status of the run. See Run states for a full list of possible run states. View runs and their properties within the run’s project workspace on the W&B App. You can also programmatically access run properties with the wandb.Api.Run object. As an example, consider the following code snippet that initializes a W&B run and logs some metrics to it:
Pass your W&B entity to the entity variable in the code snippets below if you want to follow along. Your entity is your W&B username or team name. You can find it in the URL of your W&B App workspace. For example, if your workspace URL is https://wandb.ai/nico/awesome-project, then your entity is nico.
The first line imports the W&B Python SDK. The second line initializes a run in the project awesome-project under the entity nico. The third line logs the accuracy and loss of the model to that run. Within the terminal, W&B returns:
W&B returns two URLs in the terminal output. The first URL directs you to the specific run’s workspace, and the second URL directs you to the project page.
Single run workspace
Logging a metric at a single point of time might not be that useful. A more realistic example in the case of training discriminative models is to log metrics at regular intervals. For example, consider the following code snippet:
The training script calls wandb.Run.log() 10 times. Each time the script calls wandb.Run.log(), W&B logs the accuracy and loss for that epoch. Within your terminal, you should see output similar to the following:
W&B captures the simulated training loop within a single run called jolly-haze-4. This is because the script calls wandb.init() method only once. Copy and paste the URL that W&B prints from the previous output into your browser. The URL directs you to the run’s workspace in the W&B App UI. For example, the following image shows the workspace for the run jolly-haze-4:
Training run with logged metrics