File size: 2,909 Bytes
aa0bed2 e2f8b29 aa0bed2 e2f8b29 aa0bed2 e2f8b29 aa0bed2 e2f8b29 aa0bed2 e2f8b29 aa0bed2 e2f8b29 aa0bed2 e2f8b29 aa0bed2 e2f8b29 aa0bed2 e2f8b29 aa0bed2 e2f8b29 aa0bed2 e2f8b29 aa0bed2 e2f8b29 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | """Extended simulation tests — adapted for real mini-training curves."""
from __future__ import annotations
from ml_training_debugger.scenarios import sample_scenario
from ml_training_debugger.simulation import (
gen_data_batch_stats,
gen_loss_history,
gen_val_accuracy_history,
gen_val_loss_history,
)
class TestVanishingGradients:
def test_loss_barely_decreases(self):
s = sample_scenario("task_002", seed=42)
hist = gen_loss_history(s)
assert len(hist) == 20
def test_val_acc_low(self):
s = sample_scenario("task_002", seed=42)
hist = gen_val_accuracy_history(s)
assert len(hist) == 20
def test_val_loss_present(self):
s = sample_scenario("task_002", seed=42)
hist = gen_val_loss_history(s)
assert len(hist) == 20
class TestOverfitting:
def test_loss_history_present(self):
s = sample_scenario("task_004", seed=42)
hist = gen_loss_history(s)
assert len(hist) == 20
def test_val_acc_present(self):
s = sample_scenario("task_004", seed=42)
hist = gen_val_accuracy_history(s)
assert len(hist) == 20
def test_val_loss_present(self):
s = sample_scenario("task_004", seed=42)
hist = gen_val_loss_history(s)
assert len(hist) == 20
def test_data_batch_stats_clean(self):
s = sample_scenario("task_004", seed=42)
stats = gen_data_batch_stats(s)
assert stats["class_overlap_score"] == 0.0
assert stats["duplicate_ratio"] == 0.0
class TestCodeBug:
def test_loss_history(self):
s = sample_scenario("task_006", seed=42)
hist = gen_loss_history(s)
assert len(hist) == 20
def test_val_acc(self):
s = sample_scenario("task_006", seed=42)
hist = gen_val_accuracy_history(s)
assert len(hist) == 20
def test_val_loss(self):
s = sample_scenario("task_006", seed=42)
hist = gen_val_loss_history(s)
assert len(hist) == 20
class TestBatchNormEval:
def test_val_loss_present(self):
s = sample_scenario("task_005", seed=42)
hist = gen_val_loss_history(s)
assert len(hist) == 20
def test_val_acc_near_zero(self):
s = sample_scenario("task_005", seed=42)
hist = gen_val_accuracy_history(s)
# BatchNorm eval mode makes learning very poor
assert len(hist) == 20
class TestSchedulerMisconfigured:
def test_loss_history(self):
s = sample_scenario("task_007", seed=42)
hist = gen_loss_history(s)
assert len(hist) == 20
def test_val_acc(self):
s = sample_scenario("task_007", seed=42)
hist = gen_val_accuracy_history(s)
assert len(hist) == 20
def test_val_loss(self):
s = sample_scenario("task_007", seed=42)
hist = gen_val_loss_history(s)
assert len(hist) == 20
|