{"id":34034432,"url":"https://github.com/lgy112112/ikan","last_synced_at":"2026-03-11T12:11:52.724Z","repository":{"id":245563672,"uuid":"806202328","full_name":"lgy112112/ikan","owner":"lgy112112","description":"ikan: many kan variants for every body","archived":false,"fork":false,"pushed_at":"2025-07-17T04:06:53.000Z","size":2853,"stargazers_count":295,"open_issues_count":0,"forks_count":38,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-12-15T11:14:08.747Z","etag":null,"topics":["deep-learning","kan","neural-network","tutorial"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lgy112112.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-05-26T16:54:10.000Z","updated_at":"2025-12-13T14:51:42.000Z","dependencies_parsed_at":"2024-06-22T20:20:57.117Z","dependency_job_id":"5f3fd956-1883-4704-8964-6c5c6c6bdf71","html_url":"https://github.com/lgy112112/ikan","commit_stats":null,"previous_names":["lgy112112/efficient-kan-in-chinese"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lgy112112/ikan","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgy112112%2Fikan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgy112112%2Fikan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgy112112%2Fikan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgy112112%2Fikan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lgy112112","download_url":"https://codeload.github.com/lgy112112/ikan/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgy112112%2Fikan/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30380935,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T06:09:32.197Z","status":"ssl_error","status_checked_at":"2026-03-11T06:09:17.086Z","response_time":84,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","kan","neural-network","tutorial"],"created_at":"2025-12-13T19:46:17.180Z","updated_at":"2026-03-11T12:11:52.716Z","avatar_url":"https://github.com/lgy112112.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Efficient-KAN-in-Chinese\n\n本仓库收集并整理了多种基于 Kolmogorov-Arnold 网络（KAN）的高效实现，包括 FourierKAN、ChebyKAN、JacobiKAN、TaylorKAN 和 WaveletKAN 等。这些实现旨在提供对不同类型 KAN 模型的深入理解和便捷使用。为了方便观看、阅读和修改，本人基于 [Efficient-KAN](https://github.com/Blealtan/efficient-kan) 仓库的写法对变种 KAN 进行重构。\n\n---\n\n## 目录\n\n- [Efficient-KAN-in-Chinese](#efficient-kan-in-chinese)\n  - [目录](#目录)\n  - [重要须知](#重要须知)\n    - [2025-04-09](#2025-04-09)\n    - [2025-03-25](#2025-03-25)\n  - [重大更新](#重大更新)\n    - [1. 各类KAN默认参数调整](#1-各类kan默认参数调整)\n    - [2. GroupKAN](#2-groupkan)\n  - [安装](#安装)\n    - [从 PyPI 安装](#从-pypi-安装)\n    - [从 GitHub 安装（开发版本）](#从-github-安装开发版本)\n    - [从源码安装](#从源码安装)\n  - [依赖](#依赖)\n  - [使用示例](#使用示例)\n  - [简介](#简介)\n  - [实现](#实现)\n    - [KAN](#kan)\n    - [FourierKAN](#fourierkan)\n    - [ChebyKAN](#chebykan)\n    - [JacobiKAN](#jacobikan)\n    - [TaylorKAN](#taylorkan)\n    - [WaveletKAN](#waveletkan)\n  - [应用实例](#应用实例)\n  - [参考资料](#参考资料)\n  - [许可证](#许可证)\n  - [Star History](#star-history)\n\n---\n\n## 重要须知\n\n### 2025-07-17\n建议使用源码安装进行可编辑模式的安装（后文有说明），在此之后，进入 `ikan` 进行 `pip install -e .` ，可安装并使用GPU加速GroupKAN\n\n### 2025-04-09\n他妈的这次是真可以了。1.3.0版本可包外调用 `GroupKAN`\n\n### 2025-03-25\n\n~~他妈的那个GroupKAN的仓库依赖一直说某个folder不存在，请大家暂且不要使用 `pip install ikan` 安装，而是使用 `git clone https://github.com/lgy112112/Efficient-KAN-in-Chinese.git` 和 `pip install -e .` 安装。~~\n\n他妈的终于给我修复了路径问题，现在 `ikan==1.2.10` 版本可以舒畅地使用\n\n```python\nfrom ikan.GroupKAN import GroupKAN, GroupKANLinear\n```\n\n此外，如果你是windows开发者，恰好没有triton且安装报错，请\n`pip install triton-windows`\n\nwindows开发无罪！\n\n## 重大更新\n\n### 1. 各类KAN默认参数调整\n\n在深入研究各种KAN变体的性能后，我对默认参数进行了关键调整，主要针对初始化方式和缩放系数：\n\n- **所有KAN**：`scale_base`从1.0降至0.5以下\n- **ChebyKAN**：`scale_cheby`从1.0降至0.5\n- **FourierKAN**：将 `scale_fourier`从1.0降至0.3\n- **JacobiKAN**：将 `scale_jacobi`从1.0降至0.4\n- **TaylorKAN**：将 `scale_taylor`从1.0降至0.5\n- **WaveletKAN**：将 `scale_wavelet`从1.0降至0.5\n\n通过 `KAN.ipynb`可以测试，在相同迭代次数下**超越传统MLP**。测试结果显示，参数调整后的KAN模型不仅训练速度更快，收敛性更好，而且在拟合复杂函数时的精度也明显提高。\n\n### 2. GroupKAN\n\n本项目新增基于Kolmogorov-Arnold Transformer (KAT)的**GroupKAN**实现，这是KAN的一种高效变体。我在源代码基础上修复了CPU无法训练的bug，并修复了不支持2D tensor的bug：\n\n- [KAT (Kolmogorov-Arnold Transformer)](https://github.com/Adamdad/kat) - 由Xingyi Yang和Xinchao Wang开发，GroupKAN基于此实现\n- [rational_kat_cu](https://github.com/Adamdad/rational_kat_cu) - KAT的CUDA/Triton实现，为GroupKAN提供了底层支持\n- **实现原理**：使用了KAT_Group作为激活函数，替代了传统KAN中的B样条函数\n- **性能优势**：相比原始KAN，GroupKAN具有更快的训练速度和更高的计算效率\n- **CUDA支持**：底层使用CUDA/Triton实现的Rational函数，提供了卓越的性能\n- **简化结构**：采用\"先激活后线性变换\"的结构设计，这符合Kolmogorov-Arnold定理的核心思想\n\n你可以使用以下代码创建并测试GroupKAN模型：\n\n```python\nfrom ikan.GroupKAN import GroupKAN\n\n# 定义网络层结构（确保每层特征数是num_groups的倍数）\nlayers_hidden = [64, 128, 64, 32]\n\n# 创建模型\nmodel = GroupKAN(\n    layers_hidden=layers_hidden,\n    act_mode=\"swish\",  # 可选: \"gelu\", \"swish\", \"identity\"\n    drop=0.1,\n    num_groups=8\n)\n\n# 使用torchinfo查看模型结构\nfrom torchinfo import summary\nsummary(model, input_size=(16, 64))\n```\n\n---\n\n## 安装\n\n### 从 PyPI 安装\n\n可以直接通过 [PyPI](https://pypi.org/project/efficient-kan/) 使用 `pip` 进行安装：\n\n```bash\npip install ikan\n```\n\n随后请不要忘记重启一下IDE以保证安装完整。\n\n### 从 GitHub 安装（开发版本）\n\n若需要安装最新的开发版本，可以从 GitHub 仓库直接安装：\n\n```bash\npip install git+https://github.com/lgy112112/Efficient-KAN-in-Chinese.git\n```\n\n随后请不要忘记重启一下IDE以保证安装完整。\n\n### 从源码安装\n\n你也可以从源码安装：\n\n1. 克隆项目仓库：\n   ```bash\n   git clone https://github.com/lgy112112/Efficient-KAN-in-Chinese.git\n   ```\n2. 进入项目目录：\n   ```bash\n   cd Efficient-KAN-in-Chinese\n   ```\n3. 使用可编辑模式安装：\n   ```bash\n   pip install -e .\n   ```\n\n随后请不要忘记重启一下IDE以保证安装完整。\n\n---\n\n## 依赖\n\n本项目依赖以下 Python 库：\n\n- `torch\u003e=1.9.0`\n- `torchinfo`\n- `numpy`\n\n通过 `pip` 安装时会自动安装这些依赖。\n\n---\n\n## 使用示例\n\n以下是如何使用本项目的一个简单示例：\n\n```python\nfrom ikan.ChebyKAN import ChebyKAN\n\nmodel = ChebyKAN(\n    layers_hidden=layers_hidden,\n    degree=5,\n    scale_base=1.0,\n    scale_cheby=1.0,\n    base_activation=torch.nn.SiLU,\n    use_bias=True,\n)\n\nsummary(model, input_size=(64,))\n\n```\n\n---\n\n## 简介\n\nKolmogorov-Arnold 网络（KAN）是一类基于 Kolmogorov-Arnold 表示定理的神经网络架构，具有强大的非线性表达能力。本仓库对多种 KAN 的变体进行了实现，包括使用不同基函数（如傅里叶级数、Chebyshev 多项式、Jacobi 多项式、泰勒级数和小波变换）的方法。\n\n## 实现\n\n### KAN\n\n基础的 KAN 实现，使用了 B 样条作为基函数，提供了对 KAN 模型的基本理解。\n\n- 源代码：[KAN.py](ikan\\KAN.py)\n\n### FourierKAN\n\n使用傅里叶级数作为基函数的 KAN 实现，能够捕捉输入数据的周期性特征。\n\n- 源代码：[FourierKAN.py](ikan\\FourierKAN.py)\n\n### ChebyKAN\n\n使用 Chebyshev 多项式作为基函数的 KAN 实现，具有良好的数值稳定性和逼近能力。\n\n- 源代码：[ChebyKAN.py](ikan\\ChebyKAN.py)\n\n### JacobiKAN\n\n使用 Jacobi 多项式作为基函数的 KAN 实现，通过调整参数 \\( a \\) 和 \\( b \\)，可以灵活地适应不同的数据分布。\n\n- 源代码：[JacobiKAN.py](ikan\\JacobiKAN.py)\n\n### TaylorKAN\n\n使用泰勒级数展开作为基函数的 KAN 实现，适用于需要高阶非线性特征的任务。\n\n- 源代码：[TaylorKAN.py](ikan\\TaylorKAN.py)\n\n### WaveletKAN\n\n使用小波变换作为基函数的 KAN 实现，能够捕捉数据的局部特征或频域特征。\n\n- 源代码：[WaveletKAN.py](ikan\\WaveletKAN.py)\n\n## 应用实例\n\n以下是本人使用 KAN 进行的项目，欢迎大家复现并探讨：\n\n- **MIMI-MNIST 教程**：在 MNIST 数据集上应用 KAN 模型的教程，展示了如何构建和训练 KAN 来处理手写数字识别任务。\n\n  - 项目地址：[MIMI-MNIST-Tutorial](https://github.com/lgy112112/MIMI-MNIST-Tutorial)\n- **股票预测教程**：使用 KAN 模型进行股票价格预测的教程，包括数据预处理、模型构建和结果分析。\n\n  - 项目地址：[Stocks_Prediction_Tutorial](https://github.com/lgy112112/Stocks_Prediction_Tutorial)\n  - 项目地址：[KAN_Stocks](https://github.com/lgy112112/KAN_Stocks)\n- **KAN 与 VGG 在 CIFAR-10 上的比较**：比较了 KAN 模型和 VGG 网络在 CIFAR-10 数据集上的分类性能，展示了 KAN 的潜力。\n\n  - 项目地址：[KANvsVGGonCIFAR10](https://github.com/lgy112112/KANvsVGGonCIFAR10)\n\n## 参考资料\n\n特别感谢以下开源项目对本仓库的支持和贡献：\n\n- [EfficientKAN](https://github.com/Blealtan/efficient-kan)\n- [JacobiKAN](https://github.com/SpaceLearner/JacobiKAN)\n- [TaylorKAN](https://github.com/Muyuzhierchengse/TaylorKAN/)\n- [Wav-KAN](https://github.com/zavareh1/Wav-KAN)\n- [ChebyKAN](https://github.com/SynodicMonth/ChebyKAN)\n- [FourierKAN](https://github.com/GistNoesis/FourierKAN/)\n- [KAT (Kolmogorov-Arnold Transformer)](https://github.com/Adamdad/kat) - 由Xingyi Yang和Xinchao Wang开发，GroupKAN基于此实现\n- [rational_kat_cu](https://github.com/Adamdad/rational_kat_cu) - KAT的CUDA/Triton实现，为GroupKAN提供了底层支持\n\n## 许可证\n\n本项目采用 [MIT 许可证](LICENSE) 开源。\n\n## Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=lgy112112/Efficient-KAN-in-Chinese)](https://star-history.com/#lgy112112/Efficient-KAN-in-Chinese\u0026Date)\n\n---\n\n欢迎大家提出建议和改进，共同完善本仓库。如有任何问题，请提交 [Issue](https://github.com/lgy112112/Efficient-KAN-in-Chinese/issues) 或 [Pull Request](https://github.com/lgy112112/Efficient-KAN-in-Chinese/pulls)。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flgy112112%2Fikan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flgy112112%2Fikan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flgy112112%2Fikan/lists"}