Published September 21, 2025
| Version v0.1.0
Software
Open
aaronstevenwhite/spectrans: Spectrans v0.1.0
Description
Spectrans v0.1.0
This is the first public release of Spectrans, a modular library for spectral transformer implementations in PyTorch. This library provides alternatives to traditional attention mechanisms using spectral transforms.
๐ฏ Key Features
Core Implementations
- Fourier Neural Operator (FNO): Operator learning in Fourier space
- FNet: Pure Fourier transform-based token mixing
- Global Filter Network (GFNet): Learnable filters in frequency domain
- Adaptive Fourier Neural Operator (AFNO): Adaptive frequency filtering
- Wavelet Transformers: Multi-resolution analysis with wavelets
- Linear Spectral Transform (LST): Linear complexity attention alternative
- Spectral Cross-Attention: Efficient cross-attention in spectral domain
Transform Support
- Fast Fourier Transform (FFT): 1D and 2D implementations
- Discrete Cosine Transform (DCT)
- Discrete Sine Transform (DST)
- Discrete Wavelet Transform (DWT): 1D and 2D with multiple wavelet families
- Hadamard Transform
- Short-Time Fourier Transform (STFT)
Features
- ๐ง Modular Architecture: Mix and match components with registry system
- ๐ Mathematical Rigor: Proper complex number handling and gradient flow
- โก Linearithmic Complexity: O(n log n) alternatives to O(nยฒ) attention
- ๐๏ธ Configuration System: YAML-based configuration for experiments
- ๐งช Comprehensive Testing: Full test coverage with gradient checks
- ๐ Documentation: Detailed API docs and examples
๐ Requirements
- Python โฅ 3.13
- PyTorch โฅ 2.5.0
- NumPy โฅ 2.0.0
- See
pyproject.tomlfor complete dependencies
๐ Installation
pip install spectrans
๐ป Quick Start
import torch
from spectrans.models import FNet
# Create an FNet model
model = FNet(
vocab_size=30000,
hidden_dim=768,
num_layers=12,
max_sequence_length=512,
num_classes=2
)
# Or use specific components directly
from spectrans.layers.mixing import FourierMixing
mixing_layer = FourierMixing(hidden_dim=768)
# Forward pass
input_ids = torch.randint(0, 30000, (2, 128))
output = model(input_ids=input_ids)
## ๐ Documentation
Comprehensive documentation is available on [read the docs](https://spectrans.readthedocs.io).
## ๐ค Contributing
We welcome contributions! Please see our [Contributing Guide](https://github.com/aaronstevenwhite/spectrans/blob/main/CONTRIBUTING.md) for details.
## ๐ License
MIT License. See [LICENSE](https://github.com/aaronstevenwhite/spectrans/blob/main/LICENSE) file for details.
Files
aaronstevenwhite/spectrans-v0.1.0.zip
Files
(363.2 kB)
| Name | Size | Download all |
|---|---|---|
|
md5:32f743796ed932c4e4c619b30fa6e7d8
|
363.2 kB | Preview Download |
Additional details
Related works
- Is supplement to
- Software: https://github.com/aaronstevenwhite/spectrans/tree/v0.1.0 (URL)
Software
- Repository URL
- https://github.com/aaronstevenwhite/spectrans