# blealtan/efficient-kan architecture

> Architecture diagram of the GitHub repository blealtan/efficient-kan, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/blealtan/efficient-kan
- Repository: https://github.com/blealtan/efficient-kan

## Overview

##### Main Components

a) Core Components:
- Input Layer
- KAN Layer Implementation
- B-spline Basis Functions
- Weight Matrices
- Activation Functions
- Output Layer
- Training Pipeline

b) Key Features:
- Efficient Matrix Multiplication System
- Sparsification Mechanism (L1 Regularization)
- Optional Standalone Scale Spline Feature

**[Input Data] → [KAN Network] → [Output Predictions]**

**┌─ KAN Layer Implementation ─────────────────────┐**

- [Input] → [B-spline Activation] → [Linear    │
- Functions]           → [Combination]│
- ↓          │
- [Weight Matrices] ─────────────→ [Output]    │

- ┘

##### Important Elements to Highlight

a) Data Flow:

- Blue: Core computational components
- Green: Optimization features (L1 regularization)
- Yellow: Optional features (standalone scale spline)
- Gray: Input/Output interfaces

##### Technical Details

- Matrix multiplication optimization
- B-spline basis functions
- Weight initialization (Kaiming uniform)
- L1 regularization on weights

##### Implementation Details

Relationship between:
- src/efficient_kan/kan.py (core implementation)
- examples/mnist.py (usage example)
- tests/test_simple_math.py (validation)

##### Notes for Implementation

- Use UML or similar standardized notation
- Performance optimization notes
- Version/date information

##### The initialization strategy for weights

Remember to maintain a balance between showing the mathematical foundation (Kolmogorov-Arnold network principles) and the practical implementation details (efficient matrix operations).

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        ID[Input Data]
    end

    subgraph KANNetwork["KAN Network Implementation"]
        direction TB
        IL[Input Layer]
        KL[KAN Layer]:::core
        OL[Output Layer]

        subgraph KANLayerDetails["KAN Layer Details"]
            direction TB
            BSF["B-spline Basis Functions"]:::core
            WM["Weight Matrices"]:::core
            AF["Activation Functions"]:::core
            LC["Linear Combination"]:::core

            BSF --> AF
            AF --> LC
            WM --> LC
        end

        IL --> KL
        KL --> OL
        
        KANLayerDetails -.- KL
    end

    subgraph Optimization["Optimization Features"]
        direction TB
        MM["Efficient Matrix Multiplication"]:::perf
        L1["L1 Regularization"]:::perf
        SSF["Standalone Scale Spline"]:::optional
    end

    subgraph Training["Training Pipeline"]
        TP["Training Process"]:::training
    end

    ID --> IL
    OL --> OP[Output Predictions]
    
    Optimization -.- KANNetwork
    Training -.- KANNetwork

    %% Component Mappings
    click KL "https://github.com/Blealtan/efficient-kan/blob/master/src/efficient_kan/kan.py"
    click TP "https://github.com/Blealtan/efficient-kan/blob/master/examples/mnist.py"
    click MM "https://github.com/Blealtan/efficient-kan/blob/master/tests/test_simple_math.py"
    click KANNetwork "https://github.com/Blealtan/efficient-kan/blob/master/src/efficient_kan/__init__.py"

    %% Styling
    classDef core fill:#2374ab,stroke:#000,stroke-width:2px,color:#fff
    classDef perf fill:#57a773,stroke:#000,stroke-width:2px,color:#fff
    classDef optional fill:#ffc857,stroke:#000,stroke-width:2px,color:#000
    classDef training fill:#7d7abc,stroke:#000,stroke-width:2px,color:#fff

    %% Legend
    subgraph Legend
        direction TB
        C1["Core Components"]:::core
        P1["Performance Features"]:::perf
        O1["Optional Features"]:::optional
        T1["Training Components"]:::training
    end
```
