評価プロトコル:訓練損失と検証損失のギャップ分析
Agent支援工学分析
前提条件
第51日訓練ループと第42日交差エントロピー。
学習目標
訓練ステップ進行に伴う訓練・検証損失の乖離を測定し、過学習の変曲点を定義する。
手順
torch.no_grad() を用いて勾配計算を行わずに、eval_iters 個のバッチにわたってモデルを評価する estimate_loss() を定義せよ。以下の値をプロットまたは表にまとめよ:Step 0: train 4.10, val 4.12;Step 500: train 2.20, val 2.25;Step 1500: train 1.10, val 1.95。step 1000 を汎化プラトー(generalization plateau)としてマークせよ。
演習と予測記録
1. なぜ評価は no_grad と eval の下で実行すべきか?
2. 訓練損失低下に対し検証損失が上昇し始める現象は何を意味するか?
3. 最良チェックポイント選定の基準は何か?
model.eval() は Dropout を無効化し、no_grad() はメモリを節約します。
no_grad() は計算グラフを破棄してVRAMを節約し、eval() はDropoutを無効化して決定性を確保する。ギャップ拡大は過学習(暗記)を示す。最良チェックポイントは厳密に検証損失の最小値によって決定される。
標準評価規約を理解し、検証損失によるチェックポイント選定原則を説明できること。
公式ソースリソースと権利証跡
nanoGPT: model.py architecture implementation
該当セクション・タイムスタンプ: model.py: class GPT forward(idx, targets): wte + wpe, Blocks, ln_f, lm_head (returns cross-entropy loss when targets are given)
検証バージョンと日付: Git master (Verified: 2026-10-30)
Compact historical code reference for the named implementation functions; CS336 spring2025 provides the lead component exercises. Do not infer top-p, atomic persistence or cloud budget enforcement from nanoGPT.
Python, PyTorch, and Day 43-45 attention fundamentals.
Local models and classes in the curriculum mirror nanoGPT semantics directly.
比較対象候補リソースと選定評価 (2)
Original legacy TensorFlow 1.x code; nanoGPT provides clean modern PyTorch equivalent.
Includes advanced production features (RoPE, GQA), but nanoGPT's simplicity is ideal for the core Days 46-48 assembly.
Google Machine Learning Crash Course
該当セクション・タイムスタンプ: Modules: Training and Test Sets; Overfitting; Classification accuracy
検証バージョンと日付: Current online edition (Verified: 2026-10-30)
Industrial, beginner-legible treatment of training/test splitting and overfitting; complements d2l.ai's mathematical framing.
Basic algebra; short self-contained modules.
Split discipline, leakage rules, and metric definitions are fully explained inside the lesson; the course is further reading.
比較対象候補リソースと選定評価 (2)
Co-primary: deeper mathematical coverage of model selection, generalization, and optimization for the mathematics-track capstone.
Normative reference once learners call sklearn; kept as an alternative because these days teach evaluation protocol before library usage.