https://github.com/themahani/rctorch
rcTorch is a framework developed based on pyTorch for research on Reservoir Computing.
https://github.com/themahani/rctorch
echo-state force-training gpu-acceleration pytorch research reservoir reservoir-computing
Last synced: 3 months ago
JSON representation
rcTorch is a framework developed based on pyTorch for research on Reservoir Computing.
- Host: GitHub
- URL: https://github.com/themahani/rctorch
- Owner: themahani
- License: mit
- Created: 2023-10-16T19:09:28.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2026-02-26T22:18:49.000Z (5 months ago)
- Last Synced: 2026-02-27T04:38:55.974Z (5 months ago)
- Topics: echo-state, force-training, gpu-acceleration, pytorch, research, reservoir, reservoir-computing
- Language: Python
- Homepage:
- Size: 143 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://codecov.io/gh/themahani/ml-force)
[](https://github.com/themahani/ml-force)
# rcTorch
rcTorch is a Python package implementing reservoir computing architecures using pyTorch as its backbone.
This package includes various neuronal models built-in, but the reservoir can be created
using artificial neronal model built into pyTorch.
## Installation
### From PyPI
```bash
pip install rctorch
```
### From Git
```bash
git clone https://github.com/themahani/rcTorch.git
cd rcTorch
pip install -e .
```
## Usage
```python
from rctorch import Reservoir
from rctorch.models import LIF
from rctorch.supervisors import VanDerPol
from rctorch.utils import z_tranform
model_params = {
"Ne": 100, # Excitatory neurons
"Ni": 100, # Inhibitory neurons
"dt": 1e-1, # Time step for integration
"gbar": 25, # synaptic-coupling strength, can be engineered
"BIAS": 75, # BIAS current for all neurons, can be engineered
"device": torch.device("cuda" if torch.cuda.is_available() else "cpu"),
"dtype": torch.float32,
}
T = 1000
x = VanDerPol(T=T, dt=model_params["dt"], mu=1.5, tau=0.02).generate(transient_time=100)
x = z_transform(x.T) # shape (nt, 2) where `nt` is the number of time steps of generated data
x_tensor = torch.tensor(x, dtype=model_params["dtype"], device=model_params["device"])
dim = x_tensor.size(1)
res = Reservoir(
model_cls = LIF,
n_input = dim,
n_ouput = dim,
w_in_amp = 100,
**model_params
)
t_transient = 200 # transient time in [ms]
nt_transient = int(t_transient / model_params["dt"])
x_hat = res.fit_force(
x=x_tensor, # Input data (supervisor to train on)
nt_transient=nt_transient, # Transient time in time steps
ridge_reg = 1.0, # Ridge regularization coefficient
rls_steps = 20, # gap between each RLS execution in unit of time steps (i.e every 20 time steps)
ff_coef = 1 - 1e-4 # Forgetting factor for the RLS algorithm, must be in the range [0.0, 1.0]
)
```
## Documentation
Coming soon...
## License
This project is licensed under the MIT License - see the LICENSE file for details.