Code for the paper "Next Generation Reservoir Computing"

Overview

Next Generation Reservoir Computing

This is the code for the results and figures in our paper "Next Generation Reservoir Computing". They are written in Python, and require recent versions of NumPy, SciPy, and matplotlib. If you are using a Python environment like Anaconda, these are likely already installed.

Python Virtual Environment

If you are not using Anaconda, or want to run this code on the command line in vanilla Python, you can create a virtual environment with the required dependencies by running:

python3 -m venv env
./env/bin/pip install -r requirements.txt

This will install the most recent version of the requirements available to you. If you wish to use the exact versions we used, use requirements-exact.txt instead.

You can then run the individual scripts, for example:

./env/bin/python DoubleScrollNVAR-RK23.py
You might also like...
Code for the paper Learning the Predictability of the Future

Learning the Predictability of the Future Code from the paper Learning the Predictability of the Future. Website of the project in hyperfuture.cs.colu

PyTorch code for the paper: FeatMatch: Feature-Based Augmentation for Semi-Supervised Learning
PyTorch code for the paper: FeatMatch: Feature-Based Augmentation for Semi-Supervised Learning

FeatMatch: Feature-Based Augmentation for Semi-Supervised Learning This is the PyTorch implementation of our paper: FeatMatch: Feature-Based Augmentat

Code for the paper A Theoretical Analysis of the Repetition Problem in Text Generation
Code for the paper A Theoretical Analysis of the Repetition Problem in Text Generation

A Theoretical Analysis of the Repetition Problem in Text Generation This repository share the code for the paper "A Theoretical Analysis of the Repeti

Code for our ICASSP 2021 paper: SA-Net: Shuffle Attention for Deep Convolutional Neural Networks
Code for our ICASSP 2021 paper: SA-Net: Shuffle Attention for Deep Convolutional Neural Networks

SA-Net: Shuffle Attention for Deep Convolutional Neural Networks (paper) By Qing-Long Zhang and Yu-Bin Yang [State Key Laboratory for Novel Software T

Open source repository for the code accompanying the paper 'Non-Rigid Neural Radiance Fields Reconstruction and Novel View Synthesis of a Deforming Scene from Monocular Video'.
Open source repository for the code accompanying the paper 'Non-Rigid Neural Radiance Fields Reconstruction and Novel View Synthesis of a Deforming Scene from Monocular Video'.

Non-Rigid Neural Radiance Fields This is the official repository for the project "Non-Rigid Neural Radiance Fields: Reconstruction and Novel View Synt

Code for the Shortformer model, from the paper by Ofir Press, Noah A. Smith and Mike Lewis.

Shortformer This repository contains the code and the final checkpoint of the Shortformer model. This file explains how to run our experiments on the

PyTorch code for ICLR 2021 paper Unbiased Teacher for Semi-Supervised Object Detection
PyTorch code for ICLR 2021 paper Unbiased Teacher for Semi-Supervised Object Detection

Unbiased Teacher for Semi-Supervised Object Detection This is the PyTorch implementation of our paper: Unbiased Teacher for Semi-Supervised Object Detection

Official code for paper "Optimization for Oriented Object Detection via Representation Invariance Loss".

Optimization for Oriented Object Detection via Representation Invariance Loss By Qi Ming, Zhiqiang Zhou, Lingjuan Miao, Xue Yang, and Yunpeng Dong. Th

Code for our CVPR 2021 paper
Code for our CVPR 2021 paper "MetaCam+DSCE"

Joint Noise-Tolerant Learning and Meta Camera Shift Adaptation for Unsupervised Person Re-Identification (CVPR'21) Introduction Code for our CVPR 2021

Comments
  • Generalized Performance

    Generalized Performance

    I modified the code given in this repo to what I think is a more generalized version (below) where the input is an array containing points generated by any sort of process. It gives a perfect result on predicting sin functions, but on a constant linear trend gives absolutely terrible, nonsense performance. By my understanding, that is simply the nature of reservoir computing, it can't handle a trend. Is that correct?

    I would also appreciate any other insight you might have on the generalization of this function. Thanks!

    import numpy as np
    import pandas as pd
    
    
    def load_linear(long=False, shape=None, start_date: str = "2021-01-01"):
        """Create a dataset of just zeroes for testing edge case."""
        if shape is None:
            shape = (500, 5)
        df_wide = pd.DataFrame(
            np.ones(shape), index=pd.date_range(start_date, periods=shape[0], freq="D")
        )
        df_wide = (df_wide * list(range(0, shape[1]))).cumsum()
        if not long:
            return df_wide
        else:
            df_wide.index.name = "datetime"
            df_long = df_wide.reset_index(drop=False).melt(
                id_vars=['datetime'], var_name='series_id', value_name='value'
            )
            return df_long
    
    
    def load_sine(long=False, shape=None, start_date: str = "2021-01-01"):
        """Create a dataset of just zeroes for testing edge case."""
        if shape is None:
            shape = (500, 5)
        df_wide = pd.DataFrame(
            np.ones(shape),
            index=pd.date_range(start_date, periods=shape[0], freq="D"),
            columns=range(shape[1])
        )
        X = pd.to_numeric(df_wide.index, errors='coerce', downcast='integer').values
    
        def sin_func(a, X):
            return a * np.sin(1 * X) + a
        for column in df_wide.columns:
            df_wide[column] = sin_func(column, X)
        if not long:
            return df_wide
        else:
            df_wide.index.name = "datetime"
            df_long = df_wide.reset_index(drop=False).melt(
                id_vars=['datetime'], var_name='series_id', value_name='value'
            )
            return df_long
    
    
    def predict_reservoir(df, forecast_length, warmup_pts, k=2, ridge_param=2.5e-6):
        # k =  # number of time delay taps
        # pass in traintime_pts to limit as .tail() for huge datasets?
    
        n_pts = df.shape[1]
        # handle short data edge case
        min_train_pts = 10
        max_warmup_pts = n_pts - min_train_pts
        if warmup_pts >= max_warmup_pts:
            warmup_pts = max_warmup_pts if max_warmup_pts > 0 else 0
    
        traintime_pts = n_pts - warmup_pts   # round(traintime / dt)
        warmtrain_pts = warmup_pts + traintime_pts
        testtime_pts = forecast_length + 1  # round(testtime / dt)
        maxtime_pts = n_pts  # round(maxtime / dt)
    
        # input dimension
        d = df.shape[0]
        # size of the linear part of the feature vector
        dlin = k * d
        # size of nonlinear part of feature vector
        dnonlin = int(dlin * (dlin + 1) / 2)
        # total size of feature vector: constant + linear + nonlinear
        dtot = 1 + dlin + dnonlin
    
        # create an array to hold the linear part of the feature vector
        x = np.zeros((dlin, maxtime_pts))
    
        # fill in the linear part of the feature vector for all times
        for delay in range(k):
            for j in range(delay, maxtime_pts):
                x[d * delay : d * (delay + 1), j] = df[:, j - delay]
    
        # create an array to hold the full feature vector for training time
        # (use ones so the constant term is already 1)
        out_train = np.ones((dtot, traintime_pts))
    
        # copy over the linear part (shift over by one to account for constant)
        out_train[1 : dlin + 1, :] = x[:, warmup_pts - 1 : warmtrain_pts - 1]
    
        # fill in the non-linear part
        cnt = 0
        for row in range(dlin):
            for column in range(row, dlin):
                # shift by one for constant
                out_train[dlin + 1 + cnt] = (
                    x[row, warmup_pts - 1 : warmtrain_pts - 1]
                    * x[column, warmup_pts - 1 : warmtrain_pts - 1]
                )
                cnt += 1
    
        # ridge regression: train W_out to map out_train to Lorenz[t] - Lorenz[t - 1]
        W_out = (
            (x[0:d, warmup_pts:warmtrain_pts] - x[0:d, warmup_pts - 1 : warmtrain_pts - 1])
            @ out_train[:, :].T
            @ np.linalg.pinv(
                out_train[:, :] @ out_train[:, :].T + ridge_param * np.identity(dtot)
            )
        )
    
        # create a place to store feature vectors for prediction
        out_test = np.ones(dtot)  # full feature vector
        x_test = np.zeros((dlin, testtime_pts))  # linear part
    
        # copy over initial linear feature vector
        x_test[:, 0] = x[:, warmtrain_pts - 1]
    
        # do prediction
        for j in range(testtime_pts - 1):
            # copy linear part into whole feature vector
            out_test[1 : dlin + 1] = x_test[:, j]  # shift by one for constant
            # fill in the non-linear part
            cnt = 0
            for row in range(dlin):
                for column in range(row, dlin):
                    # shift by one for constant
                    out_test[dlin + 1 + cnt] = x_test[row, j] * x_test[column, j]
                    cnt += 1
            # fill in the delay taps of the next state
            x_test[d:dlin, j + 1] = x_test[0 : (dlin - d), j]
            # do a prediction
            x_test[0:d, j + 1] = x_test[0:d, j] + W_out @ out_test[:]
        return x_test[0:d, 1:]
    
    
    # note transposed from the opposite of my usual shape
    data_pts = 7000
    series = 3
    forecast_length = 10
    df_sine = load_sine(long=False, shape=(data_pts, series)).transpose().to_numpy()
    df_sine_train = df_sine[:, :-10]
    df_sine_test = df_sine[:, -10:]
    prediction_sine = predict_reservoir(df_sine_train, forecast_length=forecast_length, warmup_pts=150, k=2, ridge_param=2.5e-6)
    print(f"sine MAE {np.mean(np.abs(df_sine_test - prediction_sine))}")
    
    df_linear = load_linear(long=False, shape=(data_pts, series)).transpose().to_numpy()
    df_linear_train = df_linear[:, :-10]
    df_linear_test = df_linear[:, -10:]
    prediction_linear = predict_reservoir(df_linear_train, forecast_length=forecast_length, warmup_pts=150, k=2, ridge_param=2.5e-6)
    print(f"linear MAE {np.mean(np.abs(df_linear_test - prediction_linear))}")
    
    
    opened by winedarksea 2
  • Link to your paper

    Link to your paper

    I'm documenting here the link to your paper. I couldn't find it in the readme:


    Next generation reservoir computing

    Daniel J. Gauthier, Erik Bollt, Aaron Griffith & Wendson A. S. Barbosa 
    

    Nature Communications volume 12, Article number: 5564 (2021) https://www.nature.com/articles/s41467-021-25801-2

    opened by impredicative 1
Releases(v1.0)
Owner
OSU QuantInfo Lab
Daniel Gauthier's Research Group
OSU QuantInfo Lab
TensorFlow implementation of Barlow Twins (Barlow Twins: Self-Supervised Learning via Redundancy Reduction)

Barlow-Twins-TF This repository implements Barlow Twins (Barlow Twins: Self-Supervised Learning via Redundancy Reduction) in TensorFlow and demonstrat

Sayak Paul 36 Sep 14, 2022
For encoding a text longer than 512 tokens, for example 800. Set max_pos to 800 during both preprocessing and training.

LongScientificFormer For encoding a text longer than 512 tokens, for example 800. Set max_pos to 800 during both preprocessing and training. Some code

Athar Sefid 6 Nov 02, 2022
Escaping the Gradient Vanishing: Periodic Alternatives of Softmax in Attention Mechanism

Period-alternatives-of-Softmax Experimental Demo for our paper 'Escaping the Gradient Vanishing: Periodic Alternatives of Softmax in Attention Mechani

slwang9353 0 Sep 06, 2021
Testing and Estimation of structural breaks in Stata

xtbreak estimating and testing for many known and unknown structural breaks in time series and panel data. For an overview of xtbreak test see xtbreak

Jan Ditzen 13 Jun 19, 2022
BuildingNet: Learning to Label 3D Buildings

BuildingNet This is the implementation of the BuildingNet architecture described in this paper: Paper: BuildingNet: Learning to Label 3D Buildings Arx

16 Nov 07, 2022
A PyTorch implementation of the Relational Graph Convolutional Network (RGCN).

Torch-RGCN Torch-RGCN is a PyTorch implementation of the RGCN, originally proposed by Schlichtkrull et al. in Modeling Relational Data with Graph Conv

Thiviyan Singam 66 Nov 30, 2022
Convert openmmlab (not only mmdetection) series model to tensorrt

MMDet to TensorRT This project aims to convert the mmdetection model to TensorRT model end2end. Focus on object detection for now. Mask support is exp

JinTian 4 Dec 17, 2021
A simple root calculater for python

Root A simple root calculater Usage/Examples python3 root.py 9 3 4 # Order: number - grid - number of decimals # Output: 2.08

Reza Hosseinzadeh 5 Feb 10, 2022
load .txt to train YOLOX, same as Yolo others

YOLOX train your data you need generate data.txt like follow format (per line- one image). prepare one data.txt like this: img_path1 x1,y1,x2,y2,clas

LiMingf 18 Aug 18, 2022
RefineGNN - Iterative refinement graph neural network for antibody sequence-structure co-design (RefineGNN)

Iterative refinement graph neural network for antibody sequence-structure co-des

Wengong Jin 83 Dec 31, 2022
PyTorch implementation of "Efficient Neural Architecture Search via Parameters Sharing"

Efficient Neural Architecture Search (ENAS) in PyTorch PyTorch implementation of Efficient Neural Architecture Search via Parameters Sharing. ENAS red

Taehoon Kim 2.6k Dec 31, 2022
Point cloud processing tool library.

Point Cloud ToolBox This point cloud processing tool library can be used to process point clouds, 3d meshes, and voxels. Environment python 3.7.5 Dep

ZhangXinyun 40 Dec 09, 2022
REBEL: Relation Extraction By End-to-end Language generation

REBEL: Relation Extraction By End-to-end Language generation This is the repository for the Findings of EMNLP 2021 paper REBEL: Relation Extraction By

Babelscape 222 Jan 06, 2023
This repository contains tutorials for the py4DSTEM Python package

py4DSTEM Tutorials This repository contains tutorials for the py4DSTEM Python package. For more information about py4DSTEM, including installation ins

11 Dec 23, 2022
PyTorch implementation of Soft-DTW: a Differentiable Loss Function for Time-Series in CUDA

Soft DTW Loss Function for PyTorch in CUDA This is a Pytorch Implementation of Soft-DTW: a Differentiable Loss Function for Time-Series which is batch

Keon Lee 76 Dec 20, 2022
Learning What and Where to Draw

###Learning What and Where to Draw Scott Reed, Zeynep Akata, Santosh Mohan, Samuel Tenka, Bernt Schiele, Honglak Lee This is the code for our NIPS 201

Scott Ellison Reed 337 Nov 18, 2022
An Abstract Cyber Security Simulation and Markov Game for OpenAI Gym

gym-idsgame An Abstract Cyber Security Simulation and Markov Game for OpenAI Gym gym-idsgame is a reinforcement learning environment for simulating at

Kim Hammar 29 Dec 03, 2022
Collection of tasks for fast prototyping, baselining, finetuning and solving problems with deep learning.

Collection of tasks for fast prototyping, baselining, finetuning and solving problems with deep learning Installation

Pytorch Lightning 1.6k Jan 08, 2023
Python PID Tuner - Based on a FOPDT model obtained using a Open Loop Process Reaction Curve

PythonPID_Tuner Step 1: Takes a Process Reaction Curve in csv format - assumes data at 100ms interval (column names CV and PV) Step 2: Makes a rough e

6 Jan 14, 2022
Source code for 2021 ICCV paper "In-the-Wild Single Camera 3D Reconstruction Through Moving Water Surfaces"

In-the-Wild Single Camera 3D Reconstruction Through Moving Water Surfaces This is the PyTorch implementation for 2021 ICCV paper "In-the-Wild Single C

27 Dec 06, 2022