Temporal KAN model
Project description
TKAN: Temporal Kolmogorov-Arnold Networks
TKAN (Temporal Kolmogorov-Arnold Networks) is a neural network architecture designed to enhance multi-horizon time series forecasting. This TensorFlow implementation integrates TKAN as a layer within sequential models, facilitating the use of advanced neural network techniques in practical applications. It is the original implementation of the paper
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 with B-spline activations in a sequential model:
from temporal_kan import TKAN
import tensorflow as tf
# Example model using TKAN with B-spline activations
model = tf.keras.Sequential([
tf.keras.layers.InputLayer(input_shape=X_train_seq.shape[1:]),
TKAN(100, tkan_activations=[{'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, tkan_activations=[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, tkan_activations=['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, tkan_activations=[None for _ in range(3)], return_sequences=False, use_bias=True), # Or put None for default activation
tf.keras.layers.Dense(y_train_seq.shape[1]),
])
You can find a more complete example with comparison with LSTM in the example folder.
Activation Function Flexibility
TKAN layers are highly flexible with regards to activation functions. They can be configured using various types of activations:
- Callable classes: Custom classes like BSplineActivation allow for sophisticated configurations.
- Integers or floats: Specify an initial exponent for a simple power spline activation.
- None: Defaults to BSplineActivation with an order of 3.
- Strings: Utilizes standard TensorFlow activation functions.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tkan-0.3.0.tar.gz
.
File metadata
- Download URL: tkan-0.3.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.2 Linux/6.5.0-14-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf74f887d021bc7008ff5b7fe1653efff449c496d288de3cc5f0d35ee1ead79e |
|
MD5 | a07a9f99ef1aaae7b8b905ecfd7b44b2 |
|
BLAKE2b-256 | f088506e9eec11e53ae52c80e84deae6f06e8d85c3b6e699375ab2363f704b3c |
File details
Details for the file tkan-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: tkan-0.3.0-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.2 Linux/6.5.0-14-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e820be394c14a1dd99778b8084b7dc65e01ab17abe2dd98ce1701bed9c01822 |
|
MD5 | b1e5a72c1a04a85694c95845f3e8564c |
|
BLAKE2b-256 | a0f8ebcca3c4d04dd5e2b0ce2587c5e3273ce2b5d249a68eba76be12911583d4 |