Skip to main content

Cellular Neural Network (CeNN) for multivariate time-series forecasting

Project description

CeNN Forecasting

A PyTorch implementation of Cellular Neural Networks (CeNN) adapted for multivariate time-series forecasting.

Overview

This package provides a trainable CeNN model based on the theory of Chua & Yang (1988), adapted for temporal forecasting tasks. Key features:

  • Forward Euler discretization of the CeNN state equation with learnable step size
  • Causal masking to prevent information leakage from future time steps
  • Depthwise or cross-channel convolution modes for univariate/multivariate coupling
  • Pre-norm residual blocks with LayerNorm for stable deep stacking
  • Compatible with NeuralForecast via the CeNN wrapper class

Installation

pip install cenn-forecasting

Quick Start

Standalone usage

import torch
from cenn_forecasting import CeNNModel1D

model = CeNNModel1D(
    n_features=7,       # number of time series
    seq_length=96,      # input window length
    pred_length=24,     # forecast horizon
    hidden_dim=64,      # latent dimension
    N=2,                # number of CeNN blocks
    K=8,                # recurrent steps per layer
    dropout=0.1,
    num_layers=2,
    neighborhood=3,     # convolution kernel size (odd)
    alpha_init=0.9,     # initial integration parameter
)

x = torch.randn(32, 96, 7)  # [batch, time, features]
out = model(x)               # [32, 24, 7]

With NeuralForecast

from neuralforecast import NeuralForecast
from neuralforecast.models import CeNN
from neuralforecast.losses.pytorch import MSE

model = CeNN(
    h=96,
    input_size=512,
    n_series=7,
    hidden_dim=64,
    N=2, K=8,
    num_layers=2,
    loss=MSE(),
    max_steps=1000,
    scaler_type='robust',
    accelerator='gpu',
)

nf = NeuralForecast(models=[model], freq='h')
nf.fit(df=train_df, val_size=val_size)
forecasts = nf.predict()

Architecture

Input [B, L, C]
    │
    ├── Linear projection → [B, L, hidden_dim]
    ├── Permute → [B, hidden_dim, L]
    │
    ├── CeNN Stack (N blocks)
    │     └── CeNN Block
    │           ├── ResidualNorm + CeNNLayer (×num_layers)
    │           │     └── CeNNCell (K iterations)
    │           │           ├── v' = α·v + (1-α)·(A·tanh(v) + B·u + I)
    │           │           └── y = tanh(v')
    │           └── Final LayerNorm
    │
    ├── Linear temporal projection → [B, hidden_dim, H]
    ├── Permute → [B, H, hidden_dim]
    └── MLP prediction head → [B, H, C]

References

  • L.O. Chua and L. Yang, "Cellular Neural Networks: Theory," IEEE Trans. Circuits and Systems, 1988.
  • L.O. Chua and L. Yang, "Cellular Neural Networks: Applications," IEEE Trans. Circuits and Systems, 1988.

License

Apache 2.0

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

cenn_forecasting-0.1.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

cenn_forecasting-0.1.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file cenn_forecasting-0.1.0.tar.gz.

File metadata

  • Download URL: cenn_forecasting-0.1.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for cenn_forecasting-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f4c05f7db53687cb36823a541e5fd4c1738b470c9cca301880ab07d1f4e55da5
MD5 87148343dcec8bba45005bafa17f1c23
BLAKE2b-256 6dea7be72f0abd19cc3542be1ee423a8eab81dd7425557de17eb01563f9196c2

See more details on using hashes here.

File details

Details for the file cenn_forecasting-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cenn_forecasting-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0eaf366d71e76a74d4dea299ce7e1a5d8f89a4f9faa322b83c03ad1a947edad9
MD5 e82a7cb0d1628364d8b569b92372be93
BLAKE2b-256 a99f88bb43085be55770ec24238eeed63c0df1e27bff471b21467f802793828d

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