La boutique est ouverte

Nous construisons les machines Workstation AI pour les sites web, les agents IA et l'entraînement de LLM — configurez-les et achetez-les en ligne.

Obtenir les prix pro
Produits IA
Labs IAAgents OpenAIAgents ClaudeGrok BotCRM natif Workstation AIMarketingTous les produits
Solutions IA
IA appliquéeAgents IAIA générativeAutomatisation par IAMontée en compétence IAOffres IA pour PMELaboratoire IA d'entrepriseStations de travail IAMatériel et logiciels NVIDIACalcul accéléré NVIDIAIA privéeCloud privé GPUClusters GPUIA en périphérieIA par secteur
Services IA
Modernisation des plateformesIngénierie numériqueFondations data et IAOpérations autonomesConseil IAAutomatisation DevOpsCybersécuritéDéveloppement logicielCréation d'agentsMise en place MLOpsLocation de GPUCloud privé GPU
À propos
EntrepriseNotre histoirePartenairesTémoignages clients
Centres de données IA
Centres de données IACloud privé GPUClusters GPULocation de GPU
Analyses IASérie JevLabo de benchmarksChoix de modèles
Notes techniques
Documentation
OS LinuxUbuntuRed Hat Enterprise LinuxSUSE LinuxAlpine LinuxDebian, Rocky & AlmaLinux
Plateformes cloud d'IAAWS & Amazon BedrockGoogle Cloud & Vertex AIMicrosoft Azure & AI FoundryClouds et places de marché GPU
Centres de données IA privésPour les cabinets d'avocatsPour les cabinets comptablesPlateformes sur siteCloud entièrement sécurisé
OutilsRing PromoterJobshout
Actualités
Blog
Nous contacterSe connecter

Stations de travail IA, logiciels multi-agents IA, infrastructure GPU et solutions d'agents intelligents pour les entreprises modernes.

Nous contacter

Solutions IA

IA appliquéeAgents IAIA générativeAutomatisation par IAMontée en compétence IAOffres IA pour PMELaboratoire IA d'entrepriseIA par secteur

Produits

Tous les produitsCRM & ERP natifs Workstation AIMarketingAgents OpenAIRing PromoterJobshout

Entreprise

À proposEntrepriseCentres de données IAPourquoi WorkstationPartenairesTémoignages clientsTarifsContactTenthMatrix

Ressources

Analyses IANotes techniquesDocumentationOS LinuxPlateformes cloud d'IACentres de données IA privésBlogRechercherPlan du site
Siège social au Royaume-Uni
77-79 Marlowes, Hemel Hempstead HP1 1LFItinéraire : prenez la sortie 20 de la M25, Outer LondonN° d'entreprise: 11641870Lun - Ven : 9h00 - 18h00 GMT
+44 7515 356 146
Bureau de Belgique
Workstation SRL, Rue Vanderkindere 34, 1180 Uccle, BrusselsBE 0751.518.683Lun - Ven : 9h00 - 18h00 CET
+32 492 45 67 46
Bureau de l'Inde
#159 Sector 9, Pocket 1, DDA Flats, 110077 Dwarka, New Delhi
+91 98881 98841
Bureau de Taïwan
3F, No. 2-4, Aisi Rd., Ren'ai Dist., Keelung City 200, Taiwan基隆市仁愛區愛四路2之4號3樓Lun - Ven : 9 h 00 - 18 h 00, heure de Taïwan (GMT+8)
+886 926 892 701+32 492 45 67 46
Bureau en Estonie
Aleksander Puškini tn 30-25, 20306 Narva, EstoniaLun - Ven : 9 h 00 - 18 h 00, heure d’Estonie (EET)
+32 492 45 67 46

© 2026 Workstation AI. Tous droits réservés.

ConfidentialitéSuppression des donnéesCookiesConditions d'utilisationPlan du site web

NVIDIA, le logo NVIDIA, RTX, RTX PRO, Blackwell, CUDA, NVLink, MGX, Omniverse, Spectrum-X, Quantum, BlueField, DGX et HGX sont des marques commerciales et/ou des marques déposées de NVIDIA Corporation aux États-Unis et dans d'autres pays. AMD, le logo AMD Arrow, EPYC, Instinct, Ryzen et Threadripper sont des marques commerciales d'Advanced Micro Devices, Inc. Dell et PowerEdge sont des marques commerciales de Dell Inc. ou de ses filiales. Intel et Xeon sont des marques commerciales d'Intel Corporation ou de ses filiales. AMAX, AceleMax et LiquidMax sont des marques commerciales d'AMAX Engineering Corporation. Tous les autres noms de produits, logos et marques appartiennent à leurs propriétaires respectifs. Nous les utilisons uniquement pour identifier les produits que nous décrivons, fournissons ou prenons en charge ; leur utilisation ne signifie pas que leurs propriétaires nous cautionnent.

Loading blog...

Accueil / Blogs
AIInterpretable MlMachine LearningMLOpsPytorch

Differentiable Curves in PyTorch: Small, Auditable Models with TorchCurves

JobShout AI Blog Writer Agent (opens in a new window)16 novembre 20269 min read
73eb8640 f691 47cd 83c5 594b8fe7798d

Most machine learning models are hard to read: thousands of weights, no shape you can point at. A learnable curve is the opposite: a smooth function of one input, set by a dozen numbers, trained with the same gradient descent as any neural network. TorchCurves, a new open-source PyTorch library, makes such curves a drop-in layer. This post explains what they are, where they earn their place and how to start.

In one sentence. A differentiable parametric curve turns one number (a price, a score, an age) into an output through a smooth, few-parameter shape that PyTorch can train end to end, so you can build models whose behaviour per input can be plotted, constrained (for example "never decreasing") and signed off.

For developers: TorchCurves in Practice: Learnable B-spline and Legendre Curves in PyTorch has the code, from install to a monotone calibration curve, an additive model on tabular data, export to JSON and SciPy, tests, and real outputs from our runs.

What a differentiable curve is

A parametric curve maps a scalar input to a point. In one dimension that point is just a number, so the curve is a function f(x). The function is built from a fixed set of basis functions (simple building blocks) multiplied by coefficients (the numbers you learn) and added up. Change the coefficients and the shape changes.

"Differentiable" means you can compute how the output changes when any coefficient, or the input itself, changes. That is what lets PyTorch train the curve with gradient descent, either alone or as one layer inside a larger network.

A learnable curve: a few coefficients shape a smooth function. A smooth curve drawn by ten control points, the pink dots joined by a faint control polygon. An input value moves along the horizontal axis and a marker follows the curve; a shaded band shows that only the four nearest coefficients affect the output at any input. A side panel explains that training nudges these ten numbers by gradient descent, that the curve is the whole model for this input, and that it can be printed, plotted and reviewed.
A cubic B-spline with ten coefficients. Each pink point is a trainable number; at any input only the nearest few matter, so a change in one region does not ripple across the whole curve.

Two bases matter in practice, and TorchCurves supports both [1][2]:

  • B-splines. Piecewise polynomials joined smoothly at points called knots. Each basis function is a local bump, so each coefficient only affects a short stretch of the curve. That makes B-splines good at sharp features and easy to constrain.
  • Legendre polynomials. Global polynomials on the interval from -1 to 1. Each coefficient affects the whole curve. They are very smooth and compact, but a local kink needs many terms.

None of this is new mathematics. Penalised B-splines ("P-splines") have been a standard smoothing tool since Eilers and Marx's 1996 paper [3], and generalised additive models (GAMs) built from them are a staple of statistics. What is new is having these curves as ordinary, batched PyTorch layers that sit inside deep learning code.

TorchCurves in brief

TorchCurves was released by Alex Shtoff and described in a paper posted to arXiv on 10 November 2026 [1]. It is Apache-2.0 licensed, installs with pip install torchcurves, and version 0.3.4 requires Python 3.12+ and PyTorch 2.9+ [2][4]. Its main pieces are:

  • BSplineCurve and LegendreCurve: layers that own their coefficients. Given a batch of inputs with one column per curve, they return a point on each curve.
  • BSplineBasis: the basis without weights, for when another network predicts the coefficients.
  • Sum: adds curve outputs, which turns a set of curves into a Kolmogorov-Arnold Network (KAN) layer [5] or an additive model.
  • A functional API (bspline_curves, legendre_curves) and input maps that squash raw inputs onto the curve's interval.

A minimal, correct example (we ran it with torchcurves 0.3.4 and PyTorch 2.15 on CPU):

import torch
import torchcurves as tc

u = torch.rand(4, 3)                       # 4 samples, 3 curves
curve = tc.BSplineCurve(num_curves=3, dim=2, knots_config=8)
y = curve(u)                               # torch.Size([4, 3, 2])
y.sum().backward()                         # gradients reach curve.control_points

Note the argument names. The earlier version of this post showed BSplineCurve(num_control_points=8, degree=3, dim=1); that signature does not exist and raises a TypeError. The number of coefficients is set by knots_config, and num_curves is required.

The paper is candid about performance: the library uses classic algorithms written as vectorised PyTorch, favouring readability over custom GPU kernels. In the author's timings it is slower than SciPy or NumPy for small problems, "generally in the ballpark" of the EfficientKAN implementation for KAN training, and faster for larger batches and dimensions [1].

Why it matters to a business

The interesting property is not speed; it is that each curve is small enough to show to a person. That helps in three situations.

When someone has to sign the model off. A credit, pricing or risk model often has to be explained to a reviewer, a customer or an auditor. An additive model, prediction = bias + f1(x1) + f2(x2) + ..., can be reviewed one plotted curve at a time. With TorchCurves it trains in the same PyTorch pipeline as the rest of your models, and the whole model is a table of coefficients you can version and diff.

When the shape must follow a rule. Higher bids should not lower the chance of winning an auction; a larger claim should not lower a risk score. A B-spline whose coefficients increase is itself increasing [2], so you can build monotonicity into the model rather than hoping the data teaches it. The library's own example does exactly this for ad-auction win probability [2].

When a number needs a richer representation. Inside a recommender or transformer, a numeric feature such as "time since last visit" can be mapped by a curve to an embedding vector instead of being bucketed. This continuous-embedding use is the library's first listed use case [1][2] and builds on the author's earlier work on factorisation machines [6].

Free curve versus monotone curve on the same calibration data. Probability of a positive outcome plotted against a raw score from 0 to 1, from a real run on synthetic data. Dots are observed rates in twenty score bins. A free 20-coefficient spline, in pink, wiggles and falls in places where the score rises. A monotone spline of the same size, in green, never falls and stays close to the true probability, shown dashed. Test log-loss: free 0.3318, monotone 0.3296, true probability 0.3268.
Our run on synthetic calibration data. Same 20 coefficients: the free spline falls in 140 of 1,000 grid steps; the monotone one never does, and it scored slightly better on held-out data.

Where curves fit among other models

Curves are not a free lunch. An additive model cannot see interactions between features unless you add them explicitly. We trained six models on the same synthetic table (five features, known shapes, plus one hidden interaction) to make the trade-off concrete:

Accuracy against readability on one tabular problem. Test error (RMSE, lower is better) for six models trained on the same synthetic table of five features with one hidden interaction; noise floor 0.30. Linear regression 1.191 with 6 parameters; spline GAM 0.603 and additive TorchCurves model 0.600, both 61 parameters and readable as one curve per feature; KAN 0.471 with 480 parameters, partly readable; gradient boosting (100 trees) 0.393 and MLP 0.341 with 4,609 parameters, not readable as curves. The additive models miss the interaction by design.
Test RMSE on one synthetic problem (noise floor 0.30). The readable models miss the interaction by design; the black boxes find it. Code and full output are in the technote.
ApproachReadable?Shape constraintsBest when
Linear or logistic regressionYesSign of a slope onlyEffects really are straight lines
Spline GAM (scikit-learn, SciPy, R mgcv)Yes, one curve per featureWith extra workTabular data, mature statistical tooling wanted
TorchCurves additive or monotone layersYes, one curve per featureMonotone by construction; smoothness penaltiesThe curve must live inside a PyTorch model, or coefficients come from another network
KAN built from curvesPartly; many curves combinedPer curveResearch, scientific functions, compact nonlinear models
Gradient boosting, MLPsNo; needs post-hoc explanationLimited (boosting libraries offer monotone constraints)Accuracy first, interactions matter

If a single curve on its own is the whole job, SciPy's make_smoothing_spline fitted our test curve more closely than gradient descent did, with the smoothing level chosen automatically [8]. TorchCurves pays off when the curve is one part of something PyTorch trains.

A playbook for your first curve model

  1. Pick one decision that needs explaining. A price response, a risk score, a calibration step. Write down the rules the shape must obey (increasing, flat beyond a cap, smooth).
  2. Build the baselines first. A linear model, a scikit-learn spline GAM [7] and your current black box. They tell you what readability costs on your data.
  3. Standardise inputs and choose the input map. TorchCurves squashes raw inputs onto the curve's interval; the default "rational" map puts most knots near zero. Clamp to a known range when you can.
  4. Start with 8 to 12 B-spline coefficients per feature and a small second-difference penalty, the P-spline idea [3]. Pick the count on a validation set.
  5. Add constraints in the parameterisation, such as cumulative sums of positive steps for monotone curves, not as hopeful penalties.
  6. Export the coefficients, knots and input map to JSON and re-evaluate them outside PyTorch. We matched SciPy to within 1e-6.
  7. Review the plotted curves with the people who own the decision before you look at the accuracy table again.

Checklist

  • Inputs standardised, and the input map and scale chosen deliberately.
  • Number of coefficients chosen on validation data, not by eye.
  • Smoothness penalty on neighbouring coefficients, especially at the edges.
  • Monotone or bounded shapes enforced by construction where a rule requires it.
  • Curves plotted per feature and checked against domain expectations.
  • Coefficients, knots, degree, input map and library version stored with the model.
  • Tests: shapes, gradients (torch.autograd.gradcheck), a reference evaluation in SciPy, and monotonicity on a dense grid.

Common mistakes

  • Copying invented APIs. Check signatures against the installed version; the library renamed its input-map arguments in 0.3.0 [2].
  • Feeding raw, unscaled features. Values far outside the knot range are squashed or clamped, and the curve goes flat where your data actually lives.
  • Too many coefficients, no penalty. In our calibration run the last unpenalised coefficient drifted to 32.6 on the logit scale, driven by a handful of points near the edge. A penalty of 0.001 brought it to 5.1.
  • Calling an additive model "explainable" and stopping there. It is readable, but it still misses interactions. Measure what that costs.
  • Exporting with a fixed batch size. torch.export fixes the batch dimension unless you mark it dynamic; our first export refused any batch but 8.

What to do this week

  1. Install torchcurves in a throwaway environment and run the hello-world above.
  2. Pick one model your team struggles to explain and fit a spline GAM baseline to it in scikit-learn.
  3. Rebuild one input of that model as a TorchCurves monotone curve and plot it next to the old behaviour.
  4. Write the JSON export and a SciPy re-evaluation test, so the curve can be audited without PyTorch.
  5. Show the plots to the person who signs the model off and note what they ask.

If you want help building interpretable models into a production MLOps pipeline, with versioned coefficients, tests and monitoring, see our MLOps setup service.

References

  1. A. Shtoff, "TorchCurves: Differentiable Parametric Curves", arXiv:2611.14516, November 2026
  2. alexshtf/torchcurves on GitHub: README, source and release notes (v0.3.4)
  3. P. H. C. Eilers and B. D. Marx, "Flexible smoothing with B-splines and penalties", Statistical Science 11(2), 1996
  4. torchcurves on PyPI
  5. Z. Liu et al., "KAN: Kolmogorov-Arnold Networks", ICLR 2025
  6. A. Shtoff, E. Abboud, R. Stram, O. Somekh, "Function Basis Encoding of Numerical Features in Factorization Machines", TMLR 2024
  7. scikit-learn: SplineTransformer
  8. SciPy: make_smoothing_spline