Claude Skills
CollectionsCompareWorkflowsNominate
Sign inSign up
© 2026 Curated Agent Skills·Learn more about Agent Skills
Back to repository

experiment-setup

verified

Hydra を使った機械学習実験のパラメータ管理と実行方法をガイドする。 Use when user mentions "hydra", "実験管理", "config.yaml", "exp/*.yaml", or asks about ML experiment configuration management.

View on GitHub

Marketplace

pokutuna-plugins

pokutuna/claude-marketplace

Plugin

hydra-experiment

Repository

pokutuna/claude-marketplace

hydra-experiment/skills/experiment-setup/SKILL.md

Last Verified

February 4, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/pokutuna/claude-marketplace/blob/main/hydra-experiment/skills/experiment-setup/SKILL.md -a claude-code --skill experiment-setup

Installation paths:

Claude
.claude/skills/experiment-setup/
Powered by add-skill CLI

Instructions

# Hydra 実験管理ガイド

Hydra によるパラメータ管理と実験実行のパターン。

## ディレクトリ構造

```
(repository root)
├── experiments/
│   ├── 001-baseline/       # 実験ディレクトリ
│   │   ├── config.yaml
│   │   ├── exp/
│   │   │   ├── 001.yaml    # パラメータオーバーライド
│   │   │   └── 002.yaml
│   │   └── train.py
│   ├── 002-larger-model/   # 別のアプローチ
│   │   ├── config.yaml
│   │   ├── exp/
│   │   └── train.py        # 訓練コードも変わりうる
│   └── ...
├── input/                  # 入力データ
└── output/                 # 実験出力
```

実験ごとに train.py を分離できるため、モデル構造やアプローチが異なる実験を並行して管理できる。

## 設定の階層構造

```
Config
└── exp: ExpConfig          # 実験固有
    ├── name, seed, ...
    └── train: TrainConfig  # ハイパーパラメータ
```

## 1. プロジェクトルートの解決

環境変数 `PROJECT_ROOT` で解決。未設定時はスクリプト位置から自動判定:

```python
import os
from pathlib import Path

PROJECT_ROOT = Path(os.environ.get(
    "PROJECT_ROOT",
    Path(__file__).parent.parent  # experiments/001-xxx/train.py → project root
))

input_dir = PROJECT_ROOT / "input"
output_dir = PROJECT_ROOT / "output"
```

リモート環境 (Runpod 等) では起動時に設定:
```bash
export PROJECT_ROOT=/workspace/project
```

## 2. 実験設定クラス

`train.py` 内:

```python
from dataclasses import dataclass, field
from hydra.core.config_store import ConfigStore

@dataclass
class TrainConfig:
    base_model: str = "model-name"
    epoch: int = 3
    batch_size: int = 32
    learning_rate: float = 5e-5

@dataclass
class ExpConfig:
    name: str = "default"
    fold: list[int] = field(default_factory=lambda: [0, 1, 2, 3, 4])
    seed: int = 42
    debug: bool = False
    mode: str = "cv"  # cv or sub
    train: TrainConfig = field(default_factory=TrainConfig)

@dataclass
class Config:
    exp: ExpConfig
    show_config: bool = False

cs = ConfigStore.instance()
cs.store(name="default", group="exp", node=ExpConfig)
```

## 3. config.yaml (ベース設定)

`experiments/001-baseline/config.yaml`:

```yaml
defaults:
- _self_
- exp: default

exp:
  name: baseline
  fold: [0]  # 試行錯誤時は 1 fold
  seed: 1209
  debug: false
  mode: cv

show_config: false

hydra:
  output_su

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
4205 chars