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
Metadata
Release files for pyresu 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pyresu-0.1.0.tar.gz | 14.5 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyresu-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.3 kB
Release files / pyresu-0.1.0.tar.gz
| Download URL | pyresu-0.1.0.tar.gz |
|---|---|
| Size | 14.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a220aa5ceb8a722b8bba1a9ee6571dcf000af1f198042a3238743b119880b78c
|
|
BLAKE2b-256 checksum How to use checksums |
46297c05a3af78ae3a807894e6b2eb8e99d01fed0b75cda691dc8ad08429747c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 31, 2026.
Transparency logRelease files / pyresu-0.1.0-py3-none-any.whl
| Download URL | pyresu-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
750d292659b4f68204f264b50dd4773b98ffbf11b16c04ca1f1fbcbd1c082b76
|
|
BLAKE2b-256 checksum How to use checksums |
b35fe120aab93dd48efeab0a1e4dd563539743487ae6db84e91cdeb3b1c1a220
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 31, 2026.
Transparency logSecurity for pyresu 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for pyresu-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 31, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.