Chuyển đến nội dung
Skillpedia
Học máy14k · #11163

experiment-tracking-swanlab

Skill này làm gì

Skill thiết lập SwanLab, một công cụ mã nguồn mở để ghi lại và so sánh các lần huấn luyện machine learning. Skill dành cho nhà nghiên cứu muốn theo dõi thí nghiệm mà không phụ thuộc vào dịch vụ đám mây được quản lý.

Khi nào nên dùng

  • ✓Khi bạn muốn ghi số liệu, cài đặt và ghi chú cho mỗi lần huấn luyện.
  • ✓Khi bạn muốn so sánh các lần chạy theo seed, checkpoint hoặc cài đặt.
  • ✓Khi bạn muốn giữ bảng điều khiển thí nghiệm trên máy tính hoặc server của riêng mình.

Liên kết skill

https://github.com/Orchestra-Research/AI-Research-SKILLs/blob/main/13-mlops/swanlab/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/Orchestra-Research/AI-Research-SKILLs/blob/main/13-mlops/swanlab/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Bạn có thể thiết lập SwanLab cho script huấn luyện của tôi để tôi ghi lại loss và so sánh các lần chạy trên máy của mình không?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent cài SwanLab, thêm ghi log vào script với tên lần chạy và cài đặt, rồi khởi động bảng điều khiển cục bộ nếu bạn muốn. Nó cũng có thể ghi ảnh, âm thanh và văn bản, và kết nối với các framework huấn luyện phổ biến.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

SwanLab: Open-Source Experiment Tracking

When to Use This Skill

Use SwanLab when you need to:

  • Track ML experiments with metrics, configs, tags, and descriptions
  • Visualize training with scalar charts and logged media
  • Compare runs across seeds, checkpoints, and hyperparameters
  • Work locally or self-hosted instead of depending on managed SaaS
  • Integrate with PyTorch, Transformers, PyTorch Lightning, or Fastai

Deployment: Cloud, local, or self-hosted | Media: images, audio, text, GIFs, point clouds, molecules | Integrations: PyTorch, Transformers, PyTorch Lightning, Fastai

Installation

# Install SwanLab plus the media dependencies used in this skill
pip install "swanlab>=0.7.11" "pillow>=9.0.0" "soundfile>=0.12.0"

# Add local dashboard support for mode="local" and swanlab watch
pip install "swanlab[dashboard]>=0.7.11"

# Optional framework integrations
pip install transformers pytorch-lightning fastai

# Login for cloud or self-hosted usage
swanlab login

pillow and soundfile are the media dependencies used by the Image and Audio examples in this skill. swanlab[dashboard] adds the local dashboard dependency required by mode="local" and swanlab watch.

Quick Start

Basic Experiment Tracking

import swanlab

run = swanlab.init(
    project="my-project",
    experiment_name="baseline",
    config={
        "learning_rate": 1e-3,
        "epochs": 10,
        "batch_size": 32,
        "model": "resnet18",
    },
)

for epoch in range(run.config.epochs):
    train_loss = train_epoch()
    val_loss = validate()

    swanlab.log(
        {
            "train/loss": train_loss,
            "val/loss": val_loss,
            "epoch": epoch,
        }
    )

run.finish()

With PyTorch

import torch
import torch.nn as nn
import torch.optim as optim
import swanlab

run = swanlab.init(
    project="pytorch-demo",
    experiment_name="mnist-mlp",
    config={
        "learning_rate": 1e-3,
        "batch_size": 64,
        "epochs": 10,
        "hidden_size": 128,
    },
)

model = nn.Sequential(
    nn.Flatten(),
    nn.Linear(28 * 28, run.config.hidden_size),
    nn.ReLU(),
    nn.Linear(run.config.hidden_size, 10),
)
optimizer = optim.Adam(model.parameters(), lr=run.config.learning_rate)
criterion = nn.CrossEntropyLoss()

for epoch in range(run.config.epochs):
    model.train()
    for batch_idx, (data, target) in enumerate(train_loader):
        optimizer.zero_grad()
        logits = model(data)
        loss = criterion(logits, target)
        loss.backward()
        optimizer.step()

        if batch_idx % 100 == 0:
            swanlab.log(
                {
                    "train/loss": loss.item(),
                    "train/epoch": epoch,
                    "train/batch": batch_idx,
                }
            )

run.finish()

Core Concepts

1. Projects and Experiments

Project: Collection of related experiments
Experiment: Single execution of a training or evaluation workflow

import swanlab

run = swanlab.init(
    project="image-classification",
    experiment_name="resnet18-seed42",
    description="Baseline run on ImageNet subset",
    tags=["baseline", "resnet18"],
    config={
        "model": "resnet18",
        "seed": 42,
        "batch_size": 64,
        "learning_rate": 3e-4,
    },
)

print(run.id)
print(run.config.learning_rate)

2. Configuration Tracking

config = {
    "model": "resnet18",
    "seed": 42,
    "batch_size": 64,
    "learning_rate": 3e-4,
    "epochs": 20,
}

run = swanlab.init(project="my-project", config=config)

learning_rate = run.config.learning_rate
batch_size = run.config.batch_size

3. Metric Logging

# Log scalars
swanlab.log({"loss": 0.42, "accuracy": 0.91})

# Log multiple metrics
swanlab.log(
    {
        "train/loss": train_loss,
        "train/accuracy": train_acc,
        "val/loss": val_loss,
        "val/accuracy": val_acc,
        "lr": current_lr,
        "epoch": epoch,
    }
)

# Log with custom step
swanlab.log({"loss": loss}, step=global_step)

4. Media and Chart Logging

import numpy as np
import swanlab

# Image
image = np.random.randint(0, 255, (224, 224, 3), dtype=np.uint8)
swanlab.log({"examples/image": swanlab.Image(image, caption="Augmented sample")})

# Audio
wave = np.sin(np.linspace(0, 8 * np.pi, 16000)).astype("float32")
swanlab.log({"examples/audio": swanlab.Audi
Câu hỏi thường gặp

Có cần tài khoản không?

Dùng trên đám mây hoặc tự lưu trữ cần đăng nhập, còn bảng điều khiển cục bộ có thể chạy trên máy của bạn.

Nó kết nối với framework nào?

PyTorch, Transformers, PyTorch Lightning và Fastai.

Nó có hiển thị được ảnh không?

Có. Nó có thể ghi ảnh, âm thanh, văn bản, GIF, đám mây điểm và phân tử.

Chi tiết

Mô tả gốc của tác giả

Provides guidance for experiment tracking with SwanLab. Use when you need open-source run tracking, local or self-hosted dashboards, and lightweight media logging for ML workflows.

repo: Orchestra-Research/AI-Research-SKILLs

Độ phổ biến

Sao GitHub
14k
Vị trí xếp hạng
#11163
Giấy phép
MIT
Cập nhật
10/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự