This repo contains notebooks with toy examples to build intuitive understanding of Kolmogorov-Arnold Networks (KAN). The repo contains a series of Jupyter notebooks to explore concepts and code to build KANs, designed to build your understanding of KANs gradually, starting from the basics of B-splines used as activation functions and progressing through more complex scenarios including symbolic regression.
Original paper: Liu et al. 2024, KAN: Kolmogorov-Arnold Networks
Original repository: Prateek Gupta
With the help of toy examples, notebooks are structured to help in understanding both the theoretical underpinnings and practical applications of KANs.
-
- Understanding the mathematical construction of B-splines.
- Exploring how B-splines are used for functional approximation.
-
- Constructing and understanding [1, 1, 1, ..., 1] KAN configurations.
- Implementing and exploring backpropagation through stacked splines.
-
- How to expand model's capacity through grid manipulation.
- How KANs prevent catastrophic forgetting in continual learning?
-
Symbolic Regression using KANs
- Training KANs with fixed symbolic activation functions.
- Understanding the implications of symbolic regression within neural networks.
To follow these tutorials, you should have a basic understanding of machine learning concepts and be familiar with Python programming. Experience with PyTorch and Jupyter Notebooks is also recommended.
Follow these steps to run the notebooks:
- Install Miniconda or Anaconda
- From the project root, create the environment:
conda env create -f environment.yml- Activate the environment:
conda activate kan-tutorial- (Optional) Create a .env from the example and adjust as desired:
copy example.env .env # on Windows
# cp example.env .env # on macOS/Linux- Launch JupyterLab:
jupyter lab- Create and activate a virtual environment:
python -m venv .venv
# Windows
.\.venv\Scripts\activate
# macOS/Linux
# source .venv/bin/activate- Install requirements:
pip install -r requirements.txt- (Optional) Copy environment example:
copy example.env .env # on Windows
# cp example.env .env # on macOS/Linux- Start JupyterLab:
jupyter lab- The notebooks and
utils.pyusetorch,numpy, andmatplotlib. - The provided
environment.ymlpins Python 3.10 and CPU-only PyTorch by default. If you have a CUDA-capable GPU, replacecpuonlywith an appropriate CUDA package per PyTorch installation instructions.
Original repository by Prateek Gupta. https://github.com/pg2455/KAN-Tutorial
FastKAN: Very Fast Kolmogorov-Arnold Network via Radial Basis Functions. https://github.com/ZiyaoLi/fast-kan
Efficient KAN: An Efficient Implementation of Kolmogorov-Arnold Network. https://github.com/Blealtan/efficient-kan