Skip to main content

SKAN: Single-Parameterized KAN Network

English / 简体中文

Introduction

SKAN is an innovative KAN (Kolmogorov-Arnold Network) network, characterized by its core feature where each basis function depends on only one learnable parameter, as proposed in this paper [1]. This design enables SKAN to scale up to larger networks while maintaining the same number of parameters, thereby more effectively capturing complex interactions between parameters. This repository provides a complete code implementation of SKAN, including the construction of basic SKAN networks, SKAN networks with custom basis functions, and a series of learnable functions mentioned in paper [1]. The SKAN library is built on the PyTorch framework, with defined networks inheriting from PyTorch's nn.Module, ensuring full compatibility with the PyTorch ecosystem (including CUDA support).

The SKAN network also serves as an ideal example of the EKE Principle (Efficient KAN Extension Principle). The EKE Principle emphasizes that in KAN networks, network performance can be more effectively enhanced by increasing parameters rather than complicating basis functions.

Usage Guide

Installing SKAN

SKAN can be easily installed via PyPI using the following command:

pip install single-kan

Building Basic Networks

Below is a basic example of using the SKAN network, demonstrating how to construct a SKAN network for MNIST handwritten digit classification:

import torch
from skan import SKANNetwork

# Select device, prioritizing GPU if available
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
# Construct SKAN network with 784 input nodes, 100 hidden nodes, and 10 output nodes
net = SKANNetwork([784, 100, 10]).to(device)

If basis_function is not specified, the lshifted_softplus function is used by default, which performed best in the tests of paper [1]. If the device supports GPU and the relevant drivers are installed, the network in the above code will perform computations on the GPU.

Using Preset Basis Functions

The SKAN library provides multiple preset single-parameter learnable functions, which are mentioned in the paper. Here's an example of how to use a preset single-parameter learnable function:

import torch
from skan import SKANNetwork
from skan.basis import lrelu

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
# Construct SKAN network using lrelu as the basis function
net = SKANNetwork([784, 100, 10], basis_function=lrelu).to(device)

Customizing SKAN Networks

The SKAN library supports user-defined basis functions. Here's an example of a custom basis function:

import torch
import numpy as np

# Define custom basis function
def lshifted_softplus(x, k):
    return torch.log(1 + torch.exp(k*x)) - np.log(2)

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
# Construct SKAN network using the custom basis function
net = SKANNetwork([784, 100, 10], basis_function=lshifted_softplus).to(device)

Custom basis functions should accept two parameters: the input value x and a unique learnable parameter k (keep this order of parameters). It is important to ensure that the basis function supports NumPy broadcasting operations and only uses libraries built on NumPy (such as PyTorch).

Reference

[1] LSS-SKAN: Efficient Kolmogorov–Arnold Networks based on Single-Parameterized Function(submited to arxiv)

Release files for single-kan 0.2.0

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

Source distribution (sdist)

Source distribution for single-kan 0.2.0
File Size Uploaded
single_kan-0.2.0.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for single-kan 0.2.0
File Interpreter ABI Platform
single_kan-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.6 kB

Release files / single_kan-0.2.0.tar.gz

Download URL single_kan-0.2.0.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8cd75f8dbf3cac8e791230b18a9d1382ecab20e6ef3a4723aaa8374bbd031c18
BLAKE2b-256 checksum
How to use checksums
3ac59a086d70124f04e680cd47922a931380cb026fc9a9b9b33f2d1fe0362026
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.3

Release files / single_kan-0.2.0-py3-none-any.whl

Download URL single_kan-0.2.0-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1d80eb38d12a3058b7425d29c3282b9839eadb138d7693f7c5dfbff7e5450c0f
BLAKE2b-256 checksum
How to use checksums
387cb07fd405506d15ff8d72a3b364d00d76c5ff53e135aed0de76095f948389
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

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