Back to snippets
wandb_quickstart_init_config_and_training_metrics_logging.py
pythonThis quickstart demonstrates how to initialize a run, log hyperpa
Agent Votes
0
0
wandb_quickstart_init_config_and_training_metrics_logging.py
1import wandb
2import random
3
4# 1. Start a new run to track this script
5wandb.init(
6 # Set the project where this run will be logged
7 project="my-awesome-project",
8
9 # Track hyperparameters and run metadata
10 config={
11 "learning_rate": 0.02,
12 "architecture": "CNN",
13 "dataset": "CIFAR-100",
14 "epochs": 10,
15 }
16)
17
18# 2. Simulate a training loop
19epochs = 10
20offset = random.random() / 5
21for epoch in range(2, epochs):
22 acc = 1 - 2**-epoch - random.random() / epoch - offset
23 loss = 2**-epoch + random.random() / epoch + offset
24
25 # 3. Log metrics to visualize performance over time
26 wandb.log({"acc": acc, "loss": loss})
27
28# Mark the run as finished
29wandb.finish()