Skip to main content

TKAN: Temporal Kolmogorov-Arnold Networks

TKAN (Temporal Kolmogorov-Arnold Networks) is a neural network architecture designed to enhance multi-horizon time series forecasting. This Keras implementation integrates TKAN as a layer within sequential models, facilitating the use of advanced neural network techniques in practical applications. The implementation is tested to be compatatible with Tensorflow, Jax and Torch. From testing jax is the best backend in terms of performance with it, while torch is very slow (probably not well optimized for it). It is the original implementation of the paper The KAN part implementation has been inspired from efficient_kan, and is available here and works similarly to it, thus not exactly like the original implementation.

In case of performance consideration, the best setup tested used jax docker image followed by installing jax using pip install "jax[cuda12]", this is what is used in the example section where you can compare the TKAN vs LSTM vs GRU time and performance. I also discourage using as is the example for torch, it seems that currently when running test using torch backend with keras is much slower than torch directly, even for GRU or LSTM.

TKAN representation

Installation

Install TKAN directly from PyPI:

pip install tkan

Dependencies are managed using pyproject.toml.

Usage

TKAN can be used within TensorFlow models to handle complex sequential patterns in data. It's implementation reproduce architecture of RNN in tensorflow with Cell class and Layer that inherits from RNN in order to provide a perfect integrations with tensorflow. Here is an example that demonstrates how to use TKAN in a sequential model:

import keras
from tkan import TKAN


# Example model using TKAN with B-spline activations
model = keras.Sequential([
      keras.layers.InputLayer(input_shape=X_train_seq.shape[1:]),
      TKAN(100, sub_kan_configs=[{'spline_order': 3, 'grid_size': 10}, {'spline_order': 1, 'grid_size': 5}, {'spline_order': 4, 'grid_size': 6}, ], return_sequences=True, use_bias=True), #Define the params of the KANLinear as dict as here
      TKAN(100, sub_kan_configs=[1, 2, 3, 3, 4], return_sequences=True, use_bias=True), #Use float or int to specify only the exponent of the spline
      TKAN(100, sub_kan_configs=['relu', 'relu', 'relu', 'relu', 'relu'], return_sequences=True, use_bias=True), #Or use string to specify the standard tensorflow activation using Dense in sublayers instead of KANLinear
      TKAN(100, sub_kan_configs=[None for _ in range(3)], return_sequences=False, use_bias=True), # Or put None for default activation
      keras.layers.Dense(y_train_seq.shape[1]),
])

You can find a more complete example with comparison with other models in the example folder.

Please cite our work if you use this repo:

@article{genet2024tkan,
  title={Tkan: Temporal kolmogorov-arnold networks},
  author={Genet, Remi and Inzirillo, Hugo},
  journal={arXiv preprint arXiv:2405.07344},
  year={2024}
}

Shield: CC BY-NC-SA 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

CC BY-NC-SA 4.0

Metadata

Release files for tkan 0.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tkan 0.4.3
File Size Uploaded Provenance Actions
tkan-0.4.3.tar.gz 8.9 kB Without provenance Details for tkan-0.4.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tkan 0.4.3
File Interpreter ABI Platform Actions
tkan-0.4.3-py3-none-any.whl Python 3 none any Details for tkan-0.4.3-py3-none-any.whl

Total release size: 16.3 kB

Release files / tkan-0.4.3.tar.gz

Download URL tkan-0.4.3.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
25c236bdaba77e16ae5097a94980febbadb2a7f611b8640eb47f7876e2bc75b5
BLAKE2b-256 checksum
How to use checksums
ae8157e8f2418f0676f722050e905825b89817b48243ad19236b845a35207438
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.2 Linux/6.5.0-14-generic

Release files / tkan-0.4.3-py3-none-any.whl

Download URL tkan-0.4.3-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c35be624a1b2f0e23e445906ce5553674702a659e1230ca116b4ab3647d1207e
BLAKE2b-256 checksum
How to use checksums
d6ed6350433d69672bc7a3e2c7eff590d58cb4255aa085ff43d14baad822c896
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.2 Linux/6.5.0-14-generic

Security for tkan 0.4.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page