Skip to content

Examples comparing HSPMN vs Transformer for time-series forecasting (MSE, FLOPs, params, latency); reproducible.

License

Notifications You must be signed in to change notification settings

NetBr3ak/HSPMN-Examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HSPMN vs Transformer

Purpose

This repository provides a comparison between:

  • HSPMN (Hierarchical Shallow Predictive Matter Networks)
  • Transformer (standard multi-head self-attention)

For the main HSPMN repository, see: https://github.com/NetBr3ak/HSPMN

Files

  1. compare.py - trains both models on identical data and reports MSE, FLOPs, parameters, and latency.
  2. verify.py - verification suite to check fairness, FLOPs counting, parameter counts, gradient flow, and reproducibility.

Quick Start

If using a POSIX shell (bash/zsh):

source venv/bin/activate
pip install -r requirements.txt
python compare.py
python verify.py

If using Windows PowerShell:

./venv/Scripts/Activate.ps1
pip install -r requirements.txt
python .\compare.py
python .\verify.py

Scripts emit summary plots (loss_curves.png, flops_comparison.png, mse_comparison.png, latency_comparison.png) and the latest metrics JSON under artifacts/.

Visual summary (latest run)

Loss curves

FLOPs comparison

MSE comparison

Latency comparison

Fairness and Metrics

  • Identical data, optimizer (Adam, lr=0.001), epochs (100), batch size (128), loss (MSE), seed (42)
  • Metrics: MSE (accuracy), FLOPs (compute), Parameters (size), Latency (inference time)

Task

Multi-scale time series forecasting (sum of three sinusoids + noise). Predict at horizons t+1, t+5, t+20 using input length 64.

Representative Results (seed=42)

  • HSPMN: MSE=0.00322, Params=0.41M, FLOPs=0.41M, Latency≈0.58ms
  • Transformer: MSE=0.00423, Params=0.62M, FLOPs=40.92M, Latency≈0.23ms

Interpretation: HSPMN achieves lower MSE and ~101× fewer FLOPs on this task, but is slower in wall-clock time due to limited parallelism in the current implementation. Results are reproducible and verified by verify.py.

Notes on Implementation

  • HSPMN implements: hierarchical predictive modules, parallel shallow processing, non-reciprocal routing, and oscillatory synchronization (additive modulation)
  • Dynamic connectivity weights are learned via backprop in this implementation; explicit active-matter update rules are planned as future work

License

MIT License.

About

Examples comparing HSPMN vs Transformer for time-series forecasting (MSE, FLOPs, params, latency); reproducible.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages