TorchCurves:可微参数曲线

·

研究论文 · 2026/11/11

TorchCurves 是一个 PyTorch 库,将向量值参数曲线作为可学习基元。其核心操作将批量标量输入映射到 B 样条或勒让德多项式基表示的曲线上的点,并支持对输入和系数进行微分。曲线系数可与周围模型联合优化,或由另一个网络生成。该库提供可训练模块、可复用基模块和函数式接口,支持从连续特征嵌入到 Kolmogorov-Arnold 网络和函数回归等应用。其实现结合经典求值算法与向量化 PyTorch 操作,强调可读性和可维护性,无需自定义硬件内核。计时实验比较了曲线求值与 NumPy、SciPy 以及 KAN 训练与 EfficientKAN 在不同问题规模下的表现,结果展示了这种通用性在何处计算上仍实用、何处开销显著。库已在 GitHub 上开源。

该库为连续特征嵌入和 KAN 等应用提供了灵活的可微分曲线基元,其性能分析有助于判断实际适用场景。

We present TorchCurves, a PyTorch library that treats vector-valued parametric curves as learnable primitives. Its central operation maps batches of scalar inputs to points on curves represented in B-spline or Legendre polynomial bases, with differentiation through both inputs and coefficients. Curve coefficients can be optimized jointly with the surrounding model or produced by another network. The library provides trainable modules, reusable basis modules, and a functional interface, supporting applications ranging from continuous feature embeddings to Kolmogorov-Arnold networks and functional regression. Its implementation combines classical evaluation algorithms with vectorized PyTorch operations, emphasizing readability and maintainability without custom hardware kernels. Timing experiments compare curve evaluation against NumPy and SciPy and KAN training against EfficientKAN across a range of problem sizes. The results illustrate where this generality remains computationally practical and where overhead is substantial. Library is available on GitHub at https://github.com/alexshtf/torchcurves.

阅读原文

参与讨论