BSplineCurve#
- class torchcurves.BSplineCurve(num_curves, dim, degree=3, knots_config=10, parameter_range=None, input_map='real.rational')#
PyTorch module for B-spline curves with learnable control points, supporting a batch of multiple curves.
The learnable parameters are the control points of \(M\) curves in \(\mathbb{R}^D\). All curves share the same degree and knot configuration. Internally, this module stores the shared spline basis in a
BSplineBasismodule.The input of this layer is mapped to the range \([-1, 1]\) (or the range of the knots if specified differently) using the specified input map.
- Parameters:
num_curves (
int) – Number of B-spline curves to define in this module (\(M\)).dim (
int) – Dimension of each curve’s output points (\(D\)).degree (
int) – Degree of the B-spline (default: 3).knots_config (
Union[int,Tensor]) – If an int, it specifies the number of control points per curve (\(C\)). A uniformly-spaced knot vector will be automatically generated in parameter_range, which defaults to [-1, 1]. If a torch.Tensor, it explicitly specifies the knot values. The number of control points will be inferred. The tensor should be 1D.parameter_range (
Optional[Sequence[Union[int,float]]]) – Interval used when knots_config is an int. Must not be set when knots_config is a tensor.input_map (
Union[str,InputMap]) – Map from raw inputs to the spline parameter interval. Can be a dotted preset string like “real.rational” or “nonneg.rational”, a map object from torchcurves.maps, or a callable with signature f(x, out_min, out_max).
- forward(u)#
Evaluate a batch of B-spline curves.
- Parameters:
u (
Tensor) – Parameter values of size \((B, C)\), where \(B\) is the mini-batch size, and C is the number of curves, and must be equal to self.num_curves.- Returns:
Points on the B-spline curves of shape \((B, C, D)\).