Skip to main content

A Python library for dynamical systems, reservoir computing, and attention mechanisms.

Project description

AERes

Overview

AERes is a Python package for experimenting with the attention-enhanced reservoir architecture using PyTorch. This library includes modules to simulate dynamical systems like the Lorenz attractor, implement reservoir computing models, and apply linear attention mechanisms.

Installation

You can install AERes using pip:

pip install aeres

Quick Start

This guide will help you get started with the AERes library, demonstrating how to simulate a dynamical system, utilize reservoir computing, and apply both Ridge Regression and a linear attention model for analysis.

Simulating a Dynamical System

Begin by simulating a coupled Lorenz system, which is a common example of a chaotic dynamical system.

from AERes.dynamicalSystems import LorenzSimulator

# Initialize the Lorenz simulator with the 'lorenz_coupled' configuration
lorenz_simulator = LorenzSimulator(function_name='lorenz_coupled')

# Perform the simulation and retrieve the data split into training and testing sets
X_train, Y_train, X_test, Y_test = lorenz_simulator.simulate_lorenz()

Simulating a Reservoir

Process the simulated data through a reservoir computing system to enhance its features for further analysis.

from AERes.reservoir import Reservoir

# Create an instance of the Reservoir with specified parameters
reservoir = Reservoir(X_train, number_nodes=10, input_dimension=X_train.shape[1], seed=1, standardize=True)

Training a Ridge Regression Model

Utilize a simple linear model for a baseline comparison.

from sklearn.linear_model import Ridge

# Train a Ridge Regression model on the processed states
ridge_model = Ridge(alpha=1.0)
ridge_model.fit(reservoir.states, Y_train)

# Make predictions on the training data
ridge_predictions = ridge_model.predict(reservoir.states)

Implementing the Linear Attention Model

Set up and train a linear attention model to focus on important features dynamically.

from AERes.attention import LinearAttentionTrainer

# Initialize the trainer for the Linear Attention model with the reservoir states
trainer = LinearAttentionTrainer(reservoir.states, Y_train, layer_type="linear")

# Train the model over 100 epochs
trainer.train(epochs=100)

Evaluating the Models

Evaluate the performance of both models to understand their effectiveness.

# Calculate the Mean Squared Error (MSE) for the Ridge Regression model
ridge_loss = trainer.MSELoss(ridge_predictions, Y_train)
print(f'Ridge Regression MSE for training: {ridge_loss.item()}')

# Evaluate the trained attention model on the testing data
trainer.evaluate(reservoir.states, Y_test)

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

AERes-0.1.1.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

AERes-0.1.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file AERes-0.1.1.tar.gz.

File metadata

  • Download URL: AERes-0.1.1.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.12

File hashes

Hashes for AERes-0.1.1.tar.gz
Algorithm Hash digest
SHA256 acd7ccb4764e0610c8347c6a9d0af23a7c83835629f561858a45b80e75fb324e
MD5 3d58322d75d1e72cd1631ae19d43a6af
BLAKE2b-256 cd8312d0f08af0690a66b974734b02f7b8f85fd0e53f8bcce6acd2c9a70509db

See more details on using hashes here.

File details

Details for the file AERes-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: AERes-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.12

File hashes

Hashes for AERes-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 695e4b87cf49cbdc9169dc140a20cb1942cb4e704f33ad0b4c47323064a9efa7
MD5 a00ca821884d0132f36c6d35ef17b491
BLAKE2b-256 89adf38b803eb721d278c0080774bf6a995aa302808da90b03e1905ad94c8775

See more details on using hashes here.

Supported by

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