Downloads · 30 days
0
rrg314/topological-adam
topological-adam is a machine learning model from rrg314. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
A PyTorch optimizer implementing energy-stabilized α-β field coupling for gradient-based optimization. This approach combines adaptive moment estimation with topological field dynamics to improve performance on comple…
Downloads · 30 days
0
Access
Public
Updated Nov 2, 2025
Repo size
16.8 KB
Likes
0
Public
Click a slice to open those files.
.zip16.8 KB · 50%
From the Hugging Face model README
A PyTorch optimizer implementing energy-stabilized α-β field coupling for gradient-based optimization. This approach combines adaptive moment estimation with topological field dynamics to improve performance on complex optimization landscapes.
Research Contribution To our knowledge, this work represents the first implementation of energy-stabilized topological field dynamics in gradient-based optimization. The approach introduces several mathematical concepts not present in existing optimizers:
Topological Current Formulation: J = (α · ĝ) - (β · ĝ) Coupled Field Evolution: Auxiliary fields evolve through differential equations Energy Stabilization: Automatic field magnitude control via E = 0.5⟨α² + β²⟩ Topological Corrections: Parameter updates include tanh(α - β) terms Empirical Evidence Benchmark results on standard datasets demonstrate complexity-dependent improvements:
Dataset Standard Adam Topological Adam Improvement MNIST 97.70% 97.59% -0.11% Fashion-MNIST 87.97% 88.72% +0.75% CIFAR-10 68.31% 68.57% +0.26% This pattern suggests the algorithm provides benefits specifically where traditional optimizers face challenges - in complex optimization landscapes with multiple local minima.
Mathematical Foundation Core Algorithm The optimizer extends standard Adam with topological field dynamics:
J = (α · ĝ) - (β · ĝ) # where ĝ is normalized gradient
α ← (1-η)α + (η/μ₀)J·β β ← (1-η)β - (η/μ₀)J·α
E = 0.5⟨α² + β²⟩ if E ≠ target_energy: rescale_fields(α, β)
θ ← θ - lr[adam_direction + w_topo·tanh(α - β)] Theoretical Background The approach combines established principles from multiple domains:
Adaptive moment estimation (proven Adam foundation) Field theory dynamics (coupled oscillator systems) Energy conservation principles (bounded field evolution) Topological methods (non-local gradient corrections) The energy stabilization mechanism ensures numerical stability while the topological fields provide exploration capabilities beyond standard gradient descent methods.
Quick Start import torch from topological_adam import TopologicalAdam
model = YourModel() optimizer = TopologicalAdam(model.parameters(), lr=1e-3)
for batch in dataloader: optimizer.zero_grad() loss = compute_loss(model, batch) loss.backward() optimizer.step()
# Monitor topological dynamics (optional)
print(f"Energy: {optimizer.energy():.2e}, |J|: {optimizer.J_mean_abs():.2e}")
Installation git clone https://github.com/yourusername/topological-adam.git cd topological-adam pip install torch torchvision matplotlib Configuration Default Usage optimizer = TopologicalAdam(model.parameters(), lr=1e-3) Advanced Configuration optimizer = TopologicalAdam( model.parameters(), lr=1e-3, # Learning rate betas=(0.9, 0.999), # Adam momentum coefficients eta=0.02, # Field evolution rate mu0=0.5, # Coupling strength w_topo=0.15, # Topological correction weight target_energy=1e-3, # Energy stabilization target ) Parameter Guidelines Parameter Range Effect Recommendation lr 1e-4 to 1e-2 Standard learning rate Start with 1e-3 eta 0.01 to 0.05 Field evolution speed 0.02 for stability w_topo 0.05 to 0.25 Topological influence 0.15 for balance target_energy 1e-4 to 1e-2 Field magnitude control 1e-3 for most problems Benchmark Results Complete Performance Analysis Run the full benchmark suite to reproduce results:
python benchmark.py Expected output:
=== MNIST === Epoch 09 | Adam=97.70% | Topo=97.59% | Energy=5.762e-03 | |J|=2.669e-02
=== FASHION ===
Epoch 09 | Adam=87.97% | Topo=88.72% | Energy=5.762e-03 | |J|=1.799e-02
=== CIFAR === Epoch 09 | Adam=68.31% | Topo=68.57% | Energy=7.683e-03 | |J|=3.383e-02 Stability Metrics Energy Evolution:
MNIST/Fashion-MNIST: 5.762e-03 (perfectly stable) CIFAR-10: 7.683e-03 (stable, adapted to problem complexity) Topological Activity:
Healthy range: 0.01-0.06 across all datasets No numerical instability observed during training Performance Analysis When Topological Adam Excels Evidence suggests benefits in scenarios with:
✅ Complex optimization landscapes with multiple local minima ✅ Medium to high complexity problems (Fashion-MNIST, CIFAR-10) ✅ Non-convex loss surfaces requiring exploration ✅ Problems where standard optimizers plateau
When Standard Adam is Sufficient ⚪ Simple, convex-like problems (basic MNIST classification) ⚪ Memory-constrained environments (2× parameter overhead) ⚪ Applications where marginal improvements don't justify complexity
Computational Characteristics Time overhead: ~1.5× standard Adam per step Memory overhead: 2× parameter storage for auxiliary fields Benefit threshold: Improvements typically justify overhead on complex problems Hardware Support Automatic Device Detection
optimizer = TopologicalAdam(model.parameters())
Platform Compatibility CPU: Standard CPU training CUDA: GPU acceleration with automatic device placement TPU: Google Cloud TPU with XLA compilation (torch-xla required)