Skip to main content

Python library for Reservoir Computing using Echo State Networks

Project description

easyesn

easyesn is a library for recurrent neural networks using echo state networks (ESNs, also called reservoir computing) with a high level easy to use API that is closely oriented towards sklearn. It aims to make the use of ESN as easy as possible, by providing algorithms for automatic gradient based hyperparameter tuning (of ridge regression penalty, spectral radius, leaking rate and feedback scaling), as well as transient time estimation. Furtheremore, it incorporates the ability to use spatio temporal ESNs for prediction and classification of geometrically extended input signals.

easyesn can either use the CPU or make use of the GPU thanks to cupy. At the moment the use of the CPU is recommended though!

This project is based on research results for the gradient based hyperparameter optimization and transient time estimation of Luca Thiede and the spatio temporal prediction and classification techniques of Roland Zimmermann.

Getting started

Installation

The easyesn library is built using python 3. You cannot use it in a python 2.x environment. The recommended way to install easyesn at the moment is via pip. Nevertheless, you can also install easyesn on your own without pip.

pip

You can install easyesn via pip by executing

pip install easyesn

from a valid python 3.x environment, which will automatically install easyesn and its dependencies.

manually

To install the library without pip, there are four steps you have to perform:

  1. Go to the pypi page of easyesn and download the latest version as a *.tar.gz archive.
  2. Extract the archive.
  3. Open your command line/terminal and cd into the directory containing the setup.py.
  4. Execute python setup.py install to start the installation.

First steps

As already mentioned, the API is very similar to the one of sklearn, which makes it as easy as possible for beginners. For every task there is a specialized module, e.g. ClassificationESN for the classification of input signals, PredictionESN for the prediction or generation (that is a several step ahead prediction by always feeding the previous prediction back in), RegressionESN for mapping a signal to a real number, or SpatioTemporalESN for the prediction of geometrically extended input signals (for example the electric excitation on the heart surface or video frames).

Import the module typing

from easyesn import PredictionESN

Now simply fit the esn using

esn.fit(x_train, y_train, transientTime=100, verbose=1)

and predict by using

y_test_pred = esn.predict(x_test, transientTime=100, verbose=1)

For automatic hyperparamter optimization import

from easyesn.optimizers import GradientOptimizer
from easyesn.optimizers import GridSearchOptimizer

Next create a new object

esn = PredictionESN(n_input=1, n_output=1, n_reservoir=500, leakingRate=0.2, spectralRadius=0.2, regressionParameters=[1e-2])

whith a penalty 1e-2 for the ridge regression. To optimize the hyperparameter also create an optimizer object

opt = GradientOptimizer(esn, learningRate=0.001)

and use it with

validationLosses, fitLosses, inputScalings, spectralRadiuses, leakingRates, learningRates = opt.optimizeParameterForTrainError(inputDataTraining, outputDataTraining, inputDataValidation, outputDataValidation, epochs=150, transientTime=100)
validationLosses, fitLosses, penalties = opt.optimizePenalty(inputDataTraining, outputDataTraining, inputDataValidation, outputDataValidation, epochs=150, transientTime=100)

More extensive examples can be found in the examples directory.

Backends

As already mentioned in the beginning, easyesn can be used either on the CPU or on the GPU. To achieve this, all low level calculations are outsourced into a backend (similiar to the backend technology of keras). To change the backend to another backend named backendName, there are currently two ways:

  1. Modify the settings file, stored at ~/.easyesn/easyesn.json to contain to look like this:

    {
        "backend": "backendName"
    }
    

    and use easyesn without any further modification inside your code.

  2. Set the EASYESN_BACKEND environment variable to backendName and use easyesn without any further modification inside your code.

At the moment, these are supported backend names:

backend name backend type Notes
numpy numpy (CPU)
np numpy (CPU)
cupy cupy (GPU) no eig & arange function which is limiting the speed
cp cupy (GPU) no eig & arange function which is limiting the speed
torch torch (CPU/GPU) experimental (Blasting fast but tested/developed for only on PredictionESN)

To set which device the torch backend should use, use the following easyesn.json config:

{
 "backend": "torch",
 "backend_config": {
     "device": "cpu"
    }
}

where cpu can be replaced with any valid torch.device, e.g. cuda.

Notes

As of right now, the GradientOptimizer does not fully work - we are looking into this and try to fix the issue.

Documentation

Develop

Todo

At the moment the easyesn library covers not only all basic features of reservoir computing but also some new, state of the art methods for its application. Nevertheless, there are still some more things which should be implemented in future versions. In the following, these feature requests and ideas are listed together which their progress:

  • Ensemble ESNs (25%)
  • Adding support for deep learning methods as the output method (still open)
  • Improved GPU computing performance (still partially open, predictionESN done)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easyesn-0.1.6.1.tar.gz (32.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

easyesn-0.1.6.1-py2.py3-none-any.whl (39.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file easyesn-0.1.6.1.tar.gz.

File metadata

  • Download URL: easyesn-0.1.6.1.tar.gz
  • Upload date:
  • Size: 32.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for easyesn-0.1.6.1.tar.gz
Algorithm Hash digest
SHA256 609469769fc63f6bc32ffeb2de34b4dfbe7028e5b7c84abb84910d940015320b
MD5 791ab42f06fa96f7dab9205d404183c2
BLAKE2b-256 2891e80880d71a9a0453500841c89d254a6463a4127e11fb4ce1cd8bbe1ae103

See more details on using hashes here.

File details

Details for the file easyesn-0.1.6.1-py2.py3-none-any.whl.

File metadata

  • Download URL: easyesn-0.1.6.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 39.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for easyesn-0.1.6.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 35e4063a95774fea5a6f8b65b358a9897adee339ea6dd9c4ce08edac542d362c
MD5 0381d19e27eb41fb7527f1723689a713
BLAKE2b-256 b3b3bb981e228f3b4a578fb7942715effff36bd2b40e696c8729971e2024cff5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page