Kolmogorov–Arnold Networks layers with MLP and interpolation activations.
Project description
MLP-KAN
PyTorch layers for building Kolmogorov–Arnold Networks (KAN) with either learnable sinusoidal features or an interpolation-based parameterisation. The implementation relies on torch.vmap for efficient evaluation and exposes utilities to encourage smoothness in interpolated activations.
Installation
The project follows the PEP 517 pyproject.toml layout. Install the package in editable mode while developing:
pip install -e .
A pre-existing PyTorch 2.0 (or later) environment is required.
Quickstart
import torch
import torch.nn as nn
from mlp_kan import KANLayer, KANInterpoLayer, smooth_penalty
# Sinusoidal feature KAN layer stack
model = nn.Sequential(
KANLayer(2, 5),
KANLayer(5, 1),
)
x = torch.randn(16, 2)
y = model(x)
assert y.shape == (16, 1)
# Interpolation-based layer with optional smoothness penalty
interp_model = nn.Sequential(
KANInterpoLayer(2, 5, num_x=128, x_min=-3, x_max=3),
KANInterpoLayer(5, 1, num_x=256),
)
penalty = smooth_penalty(interp_model)
Experiments
Two reference scripts illustrate training and visualisation workflows:
experiment.pytrains a small model using sinusoidal features.experiment_interpolation.pyexplores the interpolation-based variant with the smoothness regulariser.
Run either script after installing the project in editable mode. Generated plots are saved to the images/temp folders referenced in the notebooks.
Visualisation
The repository includes example plots captured during the experiments, demonstrating how individual activations learn components of the target function.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mlp_kan-0.1.0.tar.gz.
File metadata
- Download URL: mlp_kan-0.1.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44d5feda538d54a706a4080dc8d890ab4a2eba2b6f429945c75e55e567ffc941
|
|
| MD5 |
f782076db65974f3cfa123edf3f0402f
|
|
| BLAKE2b-256 |
416d3697ec1b3015ac8640e389ab2c081194fe8e34c898943b87c87fec59816b
|
File details
Details for the file mlp_kan-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mlp_kan-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a6ed3fbc595a784d5c031d18b3139e32dd81fd2c6a661d7849cb67274334ffe
|
|
| MD5 |
b72a3dfb3d9e5722c7cbc9b2e8f350e5
|
|
| BLAKE2b-256 |
dcb61ac3eddaf6def47f256abc91f68fa846a28de87909cc78efb589b22545a3
|