DEV Community

Damjan Žakelj
Damjan Žakelj

Posted on

Resonant Convergence Analysis (RCA): Intelligent Early Stopping That Cuts Training Time by 35–45%

Training deep-learning models often continues long after true
convergence, wasting GPU hours.\
Resonant Convergence Analysis (RCA) is a new open-source callback
that detects real convergence by analyzing oscillation patterns in
validation loss instead of relying on naive patience counters.

What is RCA?

RCA introduces two parameters:

Symbol Meaning Typical Range


β Resonance amplitude (training stability) 0--1
ω Resonance frequency (oscillation phase) ≈6 ± 0.5

Training stops when β ≥ 0.75 and oscillations flatten below a small
Δloss threshold.

Quick Example

from resonant_learner import ResonantCallback rca = ResonantCallback( checkpoint_dir="./checkpoints", patience_steps=4, min_delta=0.003, ema_alpha=0.4, lr_reduction_factor=0.7, min_lr=1e-5, verbose=True, ) for epoch in range(epochs): train_loss = train_epoch(...) val_loss = validate(...) rca(val_loss=val_loss, model=model, optimizer=optimizer, epoch=epoch) if rca.should_stop(): print("RCA triggered early stopping.") break 
Enter fullscreen mode Exit fullscreen mode

Results (Production Validation)

Dataset Baseline RCA Compute Saved ΔAccuracy


MNIST 30 18 40% +0.12%
Fashion-MNIST 30 16 47% −0.67%
CIFAR-10 (ResNet-18) 60 45 25% +1.35%
BERT SST-2 10 7 30% −0.11%

Average compute reduction: ≈36%, accuracy preserved.

Installation

git clone https://github.com/Freeky7819/resonant-learner cd resonant-learner pip install torch torchvision pip install -U pip setuptools wheel pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124 pip install tqdm numpy pandas matplotlib timm transformers datasets pip install -e . pytest -q python verify_installation.py 
Enter fullscreen mode Exit fullscreen mode

Reproduction Commands

CIFAR-10

  • python examples/cifar10_rca.py --epochs 60 --batch-size 128 --seed 42

BERT SST-2

  • python examples/hf_bert_glue.py --task sst2 --epochs 10 --batch-size 32 --seed 42

Learn More

📄 Scientific Validation Report on
Zenodo
\
🔗 GitHub Repository\
🧠 Author: Damjan Žakelj --- Harmonic Logos

"Stop training when your model converges, not epochs later."

Top comments (0)