BSplineBasis#
- class torchcurves.BSplineBasis(degree=3, knots_config=10, parameter_range=None, input_map='real.rational')#
PyTorch module for a fixed B-spline basis.
This module stores the knot vector, spline degree, and input map, but does not own coefficients. Callers provide coefficients at evaluation time, which makes this module useful when another network predicts them.
- Parameters:
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. A uniformly spaced augmented knot vector will be generated automatically over parameter_range. If a torch.Tensor, it explicitly specifies the knot values. The number of control points will be inferred. The tensor must be 1D.parameter_range (
Optional[Sequence[Union[int,float]]]) – Interval used when generating a uniform augmented knot vector from an integer knots_config. Defaults to (-1, 1). 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, coefficients)#
Evaluate caller-supplied coefficients in this B-spline basis.
- Parameters:
u (
Tensor) – Parameter values of shape \((B, M)\), where \(B\) is the mini-batch size and \(M\) is the number of curves.coefficients (
Tensor) – Coefficients of shape \((M, C, D)\), where \(C\) is the number of control points and \(D\) is the output dimension.
- Return type:
Tensor- Returns:
Points on the B-spline curves of shape \((B, M, D)\).