Rectified Spectral Units (ReSU) implementation based on Qin et al. (2025)
Project description
pyresu: Rectified Spectral Units
pyresu is a Python package implementing Rectified Spectral Units (ReSU), a biologically inspired neural building block based on the research by Qin et al. (2025). Unlike traditional deep learning that relies on backpropagation, ReSUs learn temporal features through spectral decomposition (CCA) and rectification.
Features
- Backprop-Free Training: Implements a layer-wise, feed-forward training regime using analytical solutions.
- Spectral Learning: Uses Canonical Correlation Analysis (CCA) to align past and future temporal windows.
- Biologically Inspired: Mimics self-supervised learning in biological circuits.
- Temporal Lag Management: Built-in utilities for Hankel matrix construction and lag vector handling.
- Interpretability: Learnable filters (Canonical Directions) are directly interpretable as temporal features.
Mathematical Mapping
| Concept | Symbol | Implementation |
|---|---|---|
| Past/Future Lags | $p_t, f_t$ | construct_lag_vectors |
| Covariances | $C_{pp}, C_{ff}, C_{fp}$ | compute_covariance_matrices |
| Spectral Solution | $\Psi, \sigma_i$ | perform_truncated_cca |
| ReSU Output | $z_{t,i}^+, z_{t,i}^-$ | ReSUCell.forward (ON/OFF) |
| Mutual Info | $I_r$ | calculate_mutual_information |
Installation
Install the package in editable mode for development:
git clone https://github.com/username/pyresu.git
cd pyresu
pip install -e .
For development dependencies (tests, linting):
pip install -e ".[dev]"
Quick Start
import numpy as np
from pyresu.preprocessing import construct_lag_vectors, center_lag_vectors
from pyresu.models import ReSUCell
# 1. Prepare some time-series data
data = np.random.randn(1000, 1)
# 2. Create past and future lag vectors
# memory=10 (past), horizon=5 (future)
past, future = construct_lag_vectors(data, memory=10, horizon=5)
past_c, future_c = center_lag_vectors(past, future)
# 3. Initialize and fit the ReSU Cell
# rank=3 (number of neurons)
cell = ReSUCell(rank=3)
cell.fit(past_c, future_c)
# 4. Forward pass
on_output, off_output = cell.forward(past_c)
print(f"ON shape: {on_output.shape}") # (N, 3)
print(f"OFF shape: {off_output.shape}") # (N, 3)
Project Structure
src/pyresu/: Main implementation code.core.py: CCA and spectral solvers.models.py: ReSUCell implementation.preprocessing.py: Lag vector and whitening utilities.simulation.py: Synthetic data generators (OU processes, GP).
tests/: Comprehensive test suite usingpytestandhypothesis.
Testing
Run the tests using pytest:
pytest
References
This project incorporates research from the following paper:
- A Network of Biologically Inspired Rectified Spectral Units (ReSUs) Learns Hierarchical Features Without Error Backpropagation Shanshan Qin, Joshua L. Pughe-Sanford, Alexander Genkin, Pembe Gizem Ozdil, Philip Greengard, Anirvan M. Sengupta, Dmitri B. Chklovskii arXiv:2512.23146
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 pyresu-0.1.0.tar.gz.
File metadata
- Download URL: pyresu-0.1.0.tar.gz
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a220aa5ceb8a722b8bba1a9ee6571dcf000af1f198042a3238743b119880b78c
|
|
| MD5 |
cc329f80e3fa0d69d938a148e1a0f09b
|
|
| BLAKE2b-256 |
46297c05a3af78ae3a807894e6b2eb8e99d01fed0b75cda691dc8ad08429747c
|
Provenance
The following attestation bundles were made for pyresu-0.1.0.tar.gz:
Publisher:
publish.yml on kuslavicek/pyresu
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyresu-0.1.0.tar.gz -
Subject digest:
a220aa5ceb8a722b8bba1a9ee6571dcf000af1f198042a3238743b119880b78c - Sigstore transparency entry: 883043647
- Sigstore integration time:
-
Permalink:
kuslavicek/pyresu@584fea43a7783437b57b3ee455dfc1f5df6f8a69 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/kuslavicek
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@584fea43a7783437b57b3ee455dfc1f5df6f8a69 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyresu-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyresu-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
750d292659b4f68204f264b50dd4773b98ffbf11b16c04ca1f1fbcbd1c082b76
|
|
| MD5 |
9a3e45bfbada33b93be83ea324195bfe
|
|
| BLAKE2b-256 |
b35fe120aab93dd48efeab0a1e4dd563539743487ae6db84e91cdeb3b1c1a220
|
Provenance
The following attestation bundles were made for pyresu-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on kuslavicek/pyresu
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyresu-0.1.0-py3-none-any.whl -
Subject digest:
750d292659b4f68204f264b50dd4773b98ffbf11b16c04ca1f1fbcbd1c082b76 - Sigstore transparency entry: 883043695
- Sigstore integration time:
-
Permalink:
kuslavicek/pyresu@584fea43a7783437b57b3ee455dfc1f5df6f8a69 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/kuslavicek
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@584fea43a7783437b57b3ee455dfc1f5df6f8a69 -
Trigger Event:
release
-
Statement type: