TorchCurves Brings Learnable Differentiable Curves to PyTorch Models
A new PyTorch library turns B-spline and Legendre curves into trainable layers you can drop into KANs, embeddings, and functional regression.
- TorchCurves is a new PyTorch library treating parametric curves as differentiable, learnable primitives.
- Supports B-spline and Legendre polynomial bases with gradients through inputs and coefficients.
- Targets KANs, continuous feature embeddings, shape-restricted models, and functional regression.
- Three APIs: trainable modules, reusable basis modules, and a functional interface.
- Benchmarked against SciPy, NumPy, and EfficientKAN with mixed but honest results.
- Apache-2.0 licensed, pip-installable, pure PyTorch, with paper on arXiv.
Smooth, learnable curves appear throughout modern machine learning. Kolmogorov-Arnold Networks use them as learned edge functions, continuous embeddings use them to interpolate numeric features, and shape-restricted regression uses them to enforce properties such as monotonicity. Implementing these models in PyTorch has often required custom B-spline code or components adapted from specialized repositories.
TorchCurves packages vector-valued parametric curves as reusable, differentiable PyTorch components. The library maps batches of scalar inputs to points on curves represented by B-spline or Legendre polynomial bases. Autograd can differentiate with respect to both the inputs and the coefficients, allowing a model to learn coefficients directly or receive them from another network.
One abstraction for several curve jobs
B-splines are piecewise polynomials with local support, so evaluating an input touches only a small subset of the basis functions. Their smoothness and compact support make them useful for learned nonlinear functions. Legendre polynomials provide a global polynomial basis for models that need a different parameterization.
KANs have driven much of the recent interest in these functions. They place learnable one-dimensional functions on network edges, and many implementations represent those functions with B-splines.
This story is for Pro members
You've reached the end of the free preview. Upgrade to AlphaSignal Pro to read the full article - and everything else behind the paywall.