How kindxiaoming/pykan works
Main Components
• Core Library – Represented by the “kan” directory, which holds most of the implementation files (e.g., KANLayer.py, LBFGS.py, MLP.py, MultKAN.py, Symbolic_KANLayer.py, compiler.py, experiment.py, etc.). This is the heart of the project and implements the network layers, computational routines, and compilation logic.
• Demo & Tutorials – These can be seen in the “tutorials” and “docs” directories (and also additional example notebooks like hellokan.ipynb). They are used to demonstrate how the models run and interact with users. They also act as interactive, educational interfaces.
• Documentation & Examples – The “docs” folder contains Jupyter notebooks, rst, and configuration files for building extensive documentation. It shows conceptual explanations, usage examples, and community demos.
• Models & Configurations – The “model” directory and associated configuration files (e.g., 0.0_config.yml) indicate how pre-trained models or cached states are stored and loaded. This module may also include state management (history.txt, cache folders).
• Packaging & Continuous Integration – Files like setup.py, requirements.txt, .github/workflows (with docs.yml and publish.yml), and the pykan.egg-info directory indicate that the project is set up for packaging, dependency management, and automated CI/CD.
• External Dependencies – Illustrated in the README under “Requirements” (e.g., torch, numpy, matplotlib, scikit-learn, etc.).
Relationships and Interactions
• CI/CD and Packaging: Represent a separate component for automated tasks. Highlight that code in “setup.py”, “requirements.txt”, and the workflows in “.github/workflows” enable automated testing, documentation building, and package releases.
• Data & Hyperparameter Tuning: Although not a separate module, representing an adjustable input channel (control flow) from the user’s hyperparameter decisions (like grid, width, depth) flowing into the training loops (in the “experiment” and “compiler” modules) can convey the tuning advice as outlined in the README.
Architectural Patterns and Key Principles
• The design follows a modular pattern, where core functionalities (network structure, compilation, and training) are encapsulated in specific Python modules.
• The repository structure supports both interactive experimentation (via notebooks) and production-like model training, which is common in research-driven scientific computing projects.
• There’s a clear separation of concerns: core algorithmic implementations, user documentation/demos, and automated testing/deployment workflows.
Technologies and Frameworks
• Python (minimum version 3.9.7) is the base language.
• PyTorch (torch) is likely used in the core library for modeling layers and training routines.
• Other scientific libraries include NumPy, matplotlib, scikit-learn, sympy, and pandas.
• The use of Jupyter Notebooks is highlighted by numerous checkpoints in “tutorials”, “docs”, and “kan” directories.
• CI/CD is managed with GitHub Actions as shown in the .github/workflows directory.