Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

wandb

БесплатноБез исполняемых скриптовНе проверен

Weights & Biases platform for ML experiment tracking, hyperparameter optimization, and artifact management. Log metrics, visualize training runs, run sweeps…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

Weights & Biases (W&B)

Overview

Weights & Biases (the wandb Python package) records the config, metrics, system stats, media and files of every training run, compares runs in a web dashboard, searches hyperparameters with sweeps, and versions datasets and models as artifacts. This skill covers installation, run tracking, framework integrations, sweeps, artifacts and tables.

Instructions

Install and authenticate

pip install wandb
wandb login          # paste a personal API key from your W&B user settings

In CI or containers, skip the interactive login and export the key instead: export WANDB_API_KEY=... (read it from your secret store, never commit it). To record a run without a network or an account, set WANDB_MODE=offline and upload later with wandb sync wandb/offline-run-*; WANDB_MODE=disabled turns every call into a no-op. Self-hosted servers: set WANDB_BASE_URL.

wandb.Image needs pillow and numpy arrays need numpy; W&B does not install them for you. The package requires Python 3.10 or newer (0.31.0).

Track a run

# train.py
import random
import wandb

run = wandb.init(
    project="churn-model",
    name="resnet50-baseline",
    config={"learning_rate": 0.001, "epochs": 50, "batch_size": 32, "optimizer": "adam"},
)

for epoch in range(run.config.epochs):
    train_loss = random.uniform(0.1, 1.0) * (1 - epoch / run.config.epochs)
    val_loss = train_loss + random.uniform(0, 0.2)
    run.log({"epoch": epoch, "train/loss": train_loss, "val/loss": val_loss})

run.summary["best_val_loss"] = val_loss   # final value shown in the runs table
run.finish()

wandb.init returns the run object; prefer run.log / run.config over the module-level wandb.log / wandb.config so code also works with several runs. Metrics named group/name are grouped in the UI. with wandb.init(...) as run: finishes the run automatically.

PyTorch and Hugging Face

# pytorch_wandb.py
import torch
import torch.nn as nn
import wandb

run = wandb.init(project="pytorch-demo", config={"lr": 0.01, "epochs": 20})
model = nn.Sequential(nn.Linear(10, 64), nn.ReLU(), nn.Linear(64, 2))
run.watch(model, log="all", log_freq=100)    # gradients and parameters

optimizer = torch.optim.Adam(model.parameters(), lr=run.config.lr)
criterion = nn.CrossEntropyLoss()
x, y = torch.randn(1000, 10), torch.randint(0, 2, (1000,))

for epoch in range(run.config.epochs):
    loss = criterion(model(x), y)
    optimizer.zero_grad()
    loss.backward()
    optimizer.step()
    run.log({"loss": loss.item(), "epoch": epoch})
run.finish()

Hugging Face Trainer logs to W&B when report_to="wandb" is set in TrainingArguments; choose the project with the WANDB_PROJECT environment variable and the run name with run_name.

Sweeps

Define the search in YAML for the command line, or as a Python dict for use inside a script.

# sweep.yaml
program: train.py
method: bayes
metric:
  name: val/accuracy
  goal: maximize
parameters:
  learning_rate:
    distribution: log_uniform_values
    min: 0.0001
    max: 0.1
  batch_size:
    values: [16, 32, 64, 128]
  dropout:
    distribution: uniform
    min: 0.1
    max: 0.5
$ wandb sweep sweep.yaml            # prints the sweep ID and the agent command
$ wandb agent my-team/churn-model/k3x9q2ab --count 20

train.py calls wandb.init() with no arguments and reads the values the agent chose from run.config; it must log the metric named in metric.name. Inside Python, wandb.sweep(sweep=sweep_dict, project=...) takes a dict, not a file path, and wandb.agent(sweep_id, function=train, count=20) runs a function instead of the program.

Artifacts

# artifacts.py
import wandb

run = wandb.init(project="churn-model", job_type="data-prep")
dataset = wandb.Artifact("customer-features", type="dataset", description="Cleaned features")
dataset.add_dir("./data/processed/")
run.log_artifact(dataset)
run.finish()

run = wandb.init(project="churn-model", job_type="training")
data_dir = run.use_artifact("customer-features:latest").download()
model = wandb.Artifact("churn-classifier", type="model")
model.add_file("model.pt")
run.log_artifact(model)
run.finish()

use_artifact records lineage between the dataset and the model run. Refer to versions as name:v3, name:latest or an alias you set.

Tables and media

# tables.py
import numpy as np
import wandb

run = wandb.init(project="sentiment-eval")
run.log({"examples": [wandb.Image(np.random.rand(28, 28), caption=f"sample {i}") for i in range(5)]})

table = wandb.Table(columns=["text", "prediction", "label", "correct"])
table.add_data("Great battery life", "positive", "positive", True)
table.add_data("Arrived broken", "negative", "negative", True)
table.add_data("It is fine", "positive", "neutral", False)
run.log({"predictions": table})
run.finish()

Examples

Example 1: Add tracking to an existing training script

**Use

Полный SKILL.md на GitHub

Установить wandb в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл wandb?

Weights & Biases platform for ML experiment tracking, hyperparameter optimization, and artifact management. Log metrics, visualize training runs, run sweeps for hyperparameter tuning, and version datasets and models.

Как установить скилл wandb?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл wandb запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить wandb с