B-Spline Kolmogorov-Arnold Networks in Native R 'torch'

Implements Kolmogorov-Arnold Networks (KAN) whose edge functions are B-splines plus a residual base activation, written in native R on top of the 'torch' package. Provides Cox-de Boor basis evaluation with explicit extrapolation policies, multi-layer networks, Adam and L-BFGS training with validation, early stopping, input and output normalization, gradient clipping and reproducible seeds, adaptive (sample-based) grid updates, grid refinement, KAN-specific sparsity regularization, pruning, edge-function visualization and model persistence. A dependency-free base R reference implementation with analytic gradients is included as a numerical oracle and as a training backend that does not need 'libtorch'. The design follows Liu et al. (2024) .


splineKANr

B-spline Kolmogorov-Arnold Networks (KAN) in native R torch, with a dependency-free base R reference implementation used as a numerical oracle.

# install.packages(c("torch", "devtools")); torch::install_torch()
devtools::install()          # from the package folder
library(splineKANr)

d   <- kan_synthetic("interaction", n = 500, seed = 1)
fit <- kan_fit(d$x, d$y, hidden = 4, epochs = 200, batch_size = 64,
               grid_update_every = 10, seed = 1)
predict(fit, d$x[1:5, ])
plot(fit, layer = 1, data = d$x)
kan_validate_all()           # basis, derivative, gradient checks

Status: see NEWS.md, inst/validation/ and the verification report shipped with each release. pykan (Liu et al., 2024) is used only to produce reference numbers; the package does not depend on Python.

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("splineKANr")

0.5.1 by Thang Le-Dinh, 15 hours ago


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


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


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports graphics, grDevices, splines, stats, torch, utils

Suggests knitr, rmarkdown, testthat, jsonlite


See at CRAN