PhysRes, a framework derived from physical reservoir computing (PRC), allows for a minimal network setting to be trained and infer information (e.g. predict time series) with high accuracy (image classification: accuracy >0.97 on MNIST test dataset; time series prediction: NRMSE<0.1 on NARMA10).
In root directory, run:
pip install -e .
This baseline code is adapted from our paper:
C. Caremel, Y. Kawahara, K. Nakajima, Hysteretic reservoir, Physical Review Applied 22 (6), 064045, 2024.
To test for a simple example, simply run the script NARMA10.py.
The NRMSE is computed between prediction and target.
Hysteretic behavior can be defined as a dynamic shift, or lag, denoted
The hysteretic reservoir model size is set with
In code, the model is inititalized with physres = prc.PhysRes(u, N, x0, lamda, alpha, tau)
The input timeseries in the NARMA10 task has
The training of the output weights physres.Run():
The prediction
This can be obtained from physres.Test(0.7, Y) where the parameter 0.7 represents the ratio of the number of training samples over the total number of points in the timeseries, and Y is the target timeseries.
For MNIST, unzip MNIST-dataset.zip in the data folder first, and run the implementation of the model trained as a classifier.
Although it is recommended to keep the defaults settings, the two main hyperparameters latency and scaling can be changed for optimization on a specific task. For example a grid search can be implemented for fine-tuning. Normalization should be done with min-max for best results, but sine wave is used in the physical implementation. Also, the error can be computed with either NRMSE (recommended) or NMSE. For more details, please check: https://journals.aps.org/prapplied/abstract/10.1103/PhysRevApplied.22.064045
If you use any ideas from the paper or code in this repo, please consider citing the authors:
@article{PhysRevApplied.22.064045,
title = {Hysteretic reservoir},
author = {Caremel, Cedric and Kawahara, Yoshihiro and Nakajima, Kohei},
journal = {Phys. Rev. Appl.},
volume = {22},
issue = {6},
pages = {064045},
numpages = {15},
year = {2024},
month = {Dec},
publisher = {American Physical Society},
doi = {10.1103/PhysRevApplied.22.064045},
url = {https://link.aps.org/doi/10.1103/PhysRevApplied.22.064045}
}yapf (Google style) was used for code formatting. If you want to contribute:
pip3 install yapf --upgrade
Then, make sure you are at top level of the repo and run
bash ./scripts/format.sh