Skip to main content

ECG-inspired cyclical learning-rate scheduler with training modes

Project description

🚀 SandevistanLR — ECG-Inspired Cyclical Learning Rate

Python PyTorch TensorFlow License Contributions Welcome


🧠 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)

Official ECG P–QRS–T components

Public-domain reference:
SinusRhythmLabels.svg — Wikimedia Commons


📊 Learning-Rate Signal

SandevistanLR Preview

🧩 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)

Default ECG (normal)


📊 Warmup → Normal → Cooldown

Warmup Normal Cooldown


📊 Die → AED → Recovery

Die AED Recovery


📊 High-Energy Run Mode

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:

  1. deterministic schedules
  2. signal-based formulation
  3. explicit phase control
  4. 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

🫀 ECG Foundations


📜 License

Apache License 2.0
https://www.apache.org/licenses/LICENSE-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sandevistanlr-0.2.0.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sandevistanlr-0.2.0-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

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

Hashes for sandevistanlr-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6b6f353c29f0c688a1800b0cb5adcd422eb455ed30609b93158bf5d047b550f3
MD5 0e62207617e86bcc6eeb3b336427b8d8
BLAKE2b-256 86960ec8df5c2b0c776dc604d0a71ea9d50b113f5dc54521bee0b041e4782d5f

See more details on using hashes here.

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

Hashes for sandevistanlr-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 18aec1028dc9dd6c89e1997f883f968f25023ee6eea6fddc4ab0a7f5aa426ebd
MD5 f8601d2f11ac319c8bd6f0bf32bff7d9
BLAKE2b-256 141e35b9b4a093f7c22aa2bb870038e4ee6172328d569628501a91052860b647

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page