Kolmogorov-Arnold Networks with Interchangeable Edge Bases Using 'torch'

Implements Kolmogorov-Arnold Networks (KAN) in R on top of the 'torch' package (no 'Python' needed) with one network engine and interchangeable edge bases: Chebyshev, Legendre and Jacobi polynomials, Gaussian radial basis functions (FastKAN), Mexican hat wavelets (Bozorgasl and Chen (2024) ), safe Pade rational functions (Molina, Schramowski and Kersting (2020) ), a hybrid of SiLU, Chebyshev and radial basis parts, and squared rectified linear unit bumps (Qiu et al. (2024) ). Each layer may use a different basis, and further bases can be registered by other packages. Besides tabular regression, the same layers power graph KANs for node regression (neighbourhood aggregation with the normalized adjacency matrix, as in Kiamari, Kiamari and Krishnamachari (2024) ) and lag-window KANs for one-step time series forecasting. Provides multi-layer networks with Adam training, training-only standardization, validation-based early stopping, reproducible seeds, edge-function evaluation and plots, and model persistence. A base R reference implementation with analytic gradients serves as a numerical oracle and as a training backend that does not need 'libtorch'. The network follows Liu et al. (2024) .


thangldKANr

Kolmogorov-Arnold Networks (KAN) for regression, graphs and time series in R on top of R 'torch' (no Python needed), with one engine and interchangeable edge bases:

basis edge function reference implementation compared against
"chebyshev" Chebyshev expansion of tanh(x) SynodicMonth/ChebyKAN 5f7efdd
"rbf" Gaussian RBF + SiLU base (FastKAN) ZiyaoLi/fast-kan 17b6540
"legendre" Legendre expansion of tanh(x) OrthogPolyKANs 3b2760a
"wavelet" Mexican-hat wavelet (Wav-KAN) zavareh1/Wav-KAN f7ab521
"rational" safe Pade rational function ml-research/rational_activations 2496d91
"hybrid" SiLU + Chebyshev + RBF ChebyKAN + fast-kan components
"jacobi" Jacobi expansion of tanh(x) SpaceLearner/JacobiKAN 51d160c
"relu" squared ReLU bumps (ReLU-KAN) quiqi/relu_kan 79eab7a

Each layer may use a different basis, and other packages can add bases with register_kan_basis(). A base R oracle with analytic gradients is also a training backend without libtorch.

library(thangldKANr)
kan_bases()
m <- thangld_kan(c(2, 4, 1), basis = "chebyshev", degree = 4, seed = 1)
fit <- thangld_kan_fit(m, x, y, validation_split = 0.2, epochs = 300,
                     batch_size = 32, lr = 0.02, patience = 50, seed = 1)
thangld_kan(c(2, 4, 1), basis = c("rbf", "jacobi"), degree = 3, seed = 1)
thangld_kan_validate("both")

# graphs: node regression with neighbourhood aggregation
g <- thangld_graph_kan_simulate(n = 150, seed = 1)
gm <- thangld_graph_kan(c(2, 4, 1), basis = "chebyshev", self_branch = TRUE, seed = 1)
# time series: one-step forecasts from lag windows
tm <- thangld_temporal_kan(lags = 1:12, hidden = 4, basis = "legendre", seed = 1)

Graph KANs and lag-window KANs use the same layers, so every basis works there too (thangld_graph_kan_validate(), thangld_temporal_kan_validate()).

Status: 0.1.0; regression, one output, numeric inputs, CPU.

Validation: thangld_kan_validate(), tests/testthat, inst/validation/<basis> (Python comparisons at the pinned commits above).

License: GPL-3. Citation: citation("thangldKANr"); third-party references: inst/NOTICE.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("thangldKANr")

0.1.0 by Thang Le-Dinh, 19 hours ago


https://github.com/Thangpro9999/thangldKANr


Report a bug at https://github.com/Thangpro9999/thangldKANr/issues


Browse source code at https://github.com/cran/thangldKANr


Authors: Thang Le-Dinh [aut, cre, cph]


Documentation:   PDF Manual  


GPL-3 license


Imports graphics, stats, torch, utils

Suggests knitr, rmarkdown, testthat


See at CRAN