Skip to main content

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.py trains a small model using sinusoidal features.
  • experiment_interpolation.py explores 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mlp_kan-0.1.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

mlp_kan-0.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

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

Hashes for mlp_kan-0.1.0.tar.gz
Algorithm Hash digest
SHA256 44d5feda538d54a706a4080dc8d890ab4a2eba2b6f429945c75e55e567ffc941
MD5 f782076db65974f3cfa123edf3f0402f
BLAKE2b-256 416d3697ec1b3015ac8640e389ab2c081194fe8e34c898943b87c87fec59816b

See more details on using hashes here.

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

Hashes for mlp_kan-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a6ed3fbc595a784d5c031d18b3139e32dd81fd2c6a661d7849cb67274334ffe
MD5 b72a3dfb3d9e5722c7cbc9b2e8f350e5
BLAKE2b-256 dcb61ac3eddaf6def47f256abc91f68fa846a28de87909cc78efb589b22545a3

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