ECG-inspired cyclical learning-rate scheduler with training modes
Project description
🚀 SandevistanLR — ECG-Inspired Cyclical Learning Rate
🧠 Overview
🚀 Abstraction
SandevistanLR is a step-level learning-rate scheduler in which the learning rate evolves as a deterministic, bounded time-domain signal.
⚡ Core Idea
Replace triangle or cosine schedules with a physiologically inspired ECG waveform (P–QRS–T) that explicitly encodes warm-up, exploration, and stabilization.
📈 Control Surface
- explicit phase boundaries
- bounded energy injection
- deterministic recovery
🔁 Execution Model
- evaluated per batch
- no optimizer state coupling
- no runtime heuristics
🫀 ECG Reference (P–QRS–T)
Public-domain reference:
SinusRhythmLabels.svg — Wikimedia Commons
📊 Learning-Rate Signal
🧩 Signal Semantics
- P wave → controlled warm-up
- QRS complex → short, high-energy exploration burst
- T wave → stabilization and consolidation
The waveform is:
- bounded
- repeatable
- phase-aware
- deterministic
⚙️ Optimization Modes
🎛 Explicit schedulable regimes
- normal — baseline ECG rhythm
- run — accelerated rhythm with higher exploration energy
- die — flatline (very low constant learning rate)
- aed — flatline with controlled shock spikes
Modes are:
- defined in advance
- deterministic
- never inferred from loss
🧪 Project Status & Scope
🚧 Status
This project is actively under development.
🎯 Goal
Produce a research-grade learning-rate scheduler supported by strong empirical evidence across vision and tabular benchmarks, with results packaged for conference-ready submission (e.g., CVPR / NeurIPS / ICLR workshops).
🎯 Motivation — LLMs & Short Training Runs
⚙️ Step-level execution
SandevistanLR operates per batch, not per epoch.
This is particularly relevant for large-scale training and fine-tuning, where runs are often limited to very few epochs (sometimes only one).
📉 In these regimes:
- epoch-level LR schedules become too coarse
- warm-up + decay collapses to near-constant behavior
- restart-based heuristics lack fine-grained phase control
🫀 ECG-style “heartbeat” cycles provide:
- controlled exploration
- bounded instability
- deterministic stabilization
even under extremely tight training budgets.
🧭 Preset Configurations (Recommended)
SandevistanLR ships with ready-to-use preset configurations covering a wide range of optimization behaviors:
- warmup → normal → cooldown
- athlete-like training cycles
- intermittent flatlines
- die → aed → recovery protocols
- interval training
- stress-test / arrhythmia-style schedules
These presets encode common optimization strategies in a reproducible and inspectable form.
🗂 Where to Find the Presets
📁 Preset definitions live in:
This file defines a dictionary of named configurations (CONFIGS) and their associated:
- schedule plans
- mode sequences
- timing parameters
- learning-rate bounds
Presets are strong starting points, not constraints.
SandevistanLR is fully parameterizable, allowing users to construct arbitrarily complex schedules by tuning:
- LR bounds
- cycle length
- ECG morphology
- mode transitions
to match their training budget and stability requirements.
🎞 Visual Previews
All preset waveforms are pre-generated and available in:
Representative examples rendered below:
📊 Default ECG (normal)
📊 Warmup → Normal → Cooldown
📊 Die → AED → Recovery
📊 High-Energy Run Mode
These visualizations are intended to provide immediate, pre-training insight into each schedule’s behavior, enabling reasoning about optimization dynamics before integration into training pipelines.
📦 Installation
🚀 From PyPI
pip install sandevistanlr
🔧 From source
git clone https://github.com/takfarine/SandevistanLR.git
🔌 Usage
⚙️ PyTorch — Per-Step Control
from sandevistanlr import SandevistanScheduleBase
from sandevistanlr.adapters.pytorch import SandevistanLR
base = SandevistanScheduleBase(
steps_per_epoch=100,
epoch_plan=[("normal", 1), ("run", 6)],
lr_min=1e-6,
lr_max=2e-4,
)
sched = SandevistanLR(base)
for step in range(total_steps):
lr = sched(step)
for g in optimizer.param_groups:
g["lr"] = lr
🔌 TensorFlow / Keras — Native Schedule
from sandevistanlr import SandevistanScheduleBase, SandevistanLRTF
base = SandevistanScheduleBase(
steps_per_epoch=100,
epoch_plan=[("normal", 1), ("run", 6)],
lr_min=1e-6,
lr_max=2e-4,
)
optimizer = tf.keras.optimizers.AdamW(
learning_rate=SandevistanLRTF(base)
)
📐 Mathematical Formulation
📘 Full derivation is provided in:
Separation of concerns:
- README → systems intuition & usage
- Notebook → equations & proofs
🧩 Design Principles
Core guarantees:
- deterministic schedules
- signal-based formulation
- explicit phase control
- cross-framework numerical parity
Suitable for:
- fine-tuning
- short-budget training
- controlled ablation studies
- reproducible benchmarks
🛣 Status & Roadmap
Current status: v0.1.0 — stable core
Planned:
- benchmark reports (vision, tabular)
- additional presets
- optional integration helpers
Not planned:
- heuristic auto-tuning
- randomized schedules
- opaque optimizer logic
📚 References
📈 Learning-Rate Scheduling
-
Leslie N. Smith, Cyclical Learning Rates for Training Neural Networks (2015)
https://arxiv.org/abs/1506.01186 -
Leslie N. Smith & Nicholay Topin, Super-Convergence (2017)
https://arxiv.org/abs/1708.07120 -
Ilya Loshchilov & Frank Hutter, SGDR (2016)
https://arxiv.org/abs/1608.03983 -
fastai documentation, 1cycle policy
https://docs.fast.ai/callback.schedule.html
🫀 ECG Foundations
-
Willem Einthoven, Nobel Lecture (1925)
https://www.nobelprize.org/prizes/medicine/1924/einthoven/lecture/ -
Rivera-Ruiz et al., Einthoven’s String Galvanometer (2008)
https://pmc.ncbi.nlm.nih.gov/articles/PMC2435435/ -
Fisch, Centennial of the Electrocardiogram (2000)
https://www.sciencedirect.com/science/article/pii/S0735109700009761
📜 License
Apache License 2.0
https://www.apache.org/licenses/LICENSE-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sandevistanlr-0.2.0.tar.gz.
File metadata
- Download URL: sandevistanlr-0.2.0.tar.gz
- Upload date:
- Size: 22.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b6f353c29f0c688a1800b0cb5adcd422eb455ed30609b93158bf5d047b550f3
|
|
| MD5 |
0e62207617e86bcc6eeb3b336427b8d8
|
|
| BLAKE2b-256 |
86960ec8df5c2b0c776dc604d0a71ea9d50b113f5dc54521bee0b041e4782d5f
|
File details
Details for the file sandevistanlr-0.2.0-py3-none-any.whl.
File metadata
- Download URL: sandevistanlr-0.2.0-py3-none-any.whl
- Upload date:
- Size: 21.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18aec1028dc9dd6c89e1997f883f968f25023ee6eea6fddc4ab0a7f5aa426ebd
|
|
| MD5 |
f8601d2f11ac319c8bd6f0bf32bff7d9
|
|
| BLAKE2b-256 |
141e35b9b4a093f7c22aa2bb870038e4ee6172328d569628501a91052860b647
|