# TorchCurves: differentiable curve modules (B-spline/Legendre Poly)

**URL:** <https://discuss.pytorch.org/t/torchcurves-differentiable-curve-modules-b-spline-legendre-poly/223369>\
**Category:** Uncategorized\
**Created:** [September 28, 2025, 7:11am UTC](https://discuss.pytorch.org/t/torchcurves-differentiable-curve-modules-b-spline-legendre-poly/223369 "2025-09-28T07:11:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Shtof](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/alex_shtof/32/58286_2.png) [@Alex\_Shtof](https://discuss.pytorch.org/u/Alex_Shtof)\
**Post date:** [September 28, 2025, 7:11am UTC](https://discuss.pytorch.org/t/torchcurves-differentiable-curve-modules-b-spline-legendre-poly/223369/1 "2025-09-28T07:11:14Z")

</div>

I’ve released a small library for parametric curves for PyTorch that are differentiable: you can backprop to the curve’s inputs and to its parameters. At this stage, I have B-Spline curves (efficiently, exploiting sparsity!) and Legendre Polynomials.

Link: [GitHub - alexshtf/torchcurves: Parametric differentiable curves with PyTorch for KANs, continuous embeddings, or shape-restricted models](https://github.com/alexshtf/torchcurves)

Applications include:

- Continuous embeddings for embedding-based models (i.e. factorization machines, transformers, etc)
- KANs. You don’t have to use B-Splines. You can, in fact, use any well-approximating basis for the learned activations.
- Shape-restricted models, i.e. modeling the probability of winning an auction given auction features x and a bid b. You have a neural network c(x) that predicts the coefficients of a function of b. If you force the coefficient vector to be non-decreasing, then if used with a B-Spline you will get a non-decreasing probability, which is the right inductive bias.

I hope some of you will find it useful!
