Skip to main content
Metric names in W&B must follow GraphQL naming conventions so that you can sort and filter them in the UI.

Valid metric names

Metric names must follow these rules:
  • Allowed characters: Letters (A-Z, a-z), digits (0-9), and underscores (_).
  • Starting character: Names must start with a letter or underscore.
  • Pattern: Metric names should match /^[_a-zA-Z][_a-zA-Z0-9]*$/.
If metrics don’t follow these rules, you might not be able to sort or filter them in the W&B UI.

Examples

The following examples show metric names that comply with these rules and names that don’t. Valid metric names:
with wandb.init() as run:
  run.log({"accuracy": 0.9, "val_loss": 0.1, "epoch_5": 5})
  run.log({"modelAccuracy": 0.95, "learning_rate": 0.001})
Invalid metric names (avoid these):
with wandb.init() as run:
  run.log({"acc,val": 0.9})  # Contains comma
  run.log({"loss-train": 0.1})  # Contains hyphen
  run.log({"test acc": 0.95})  # Contains space
  run.log({"5_fold_cv": 0.8})  # Starts with number
Replace invalid characters with valid characters such as underscores:
  • Instead of "test acc", use "test_acc".
  • Instead of "loss-train", use "loss_train".
  • Instead of "acc,val", use "acc_val".
For more information, see Metric naming constraints.
Experiments Metrics