-
Notifications
You must be signed in to change notification settings - Fork 82
Open
Description
Splines are very slow and occasionally have unexpected behavior. To reproduce the error:
import torch
from pina.model import Spline
from scipy.interpolate._bsplines import BSpline
from matplotlib import pyplot as plt
seed = 1999
torch.manual_seed(seed)
x_min, x_max = 0,1
x = torch.linspace(x_min, x_max, 50)
order = 3
knots = torch.linspace(x_min, x_max, 10)
n_coeffs = len(knots) - order
control_points = torch.randn(n_coeffs)
print(control_points)
model = Spline(knots=knots, control_points=control_points, order=order)
y = model(x)
spline = BSpline(
t=knots.detach().numpy(),
c=control_points.detach().numpy(),
k=model.order - 1,
)
y_scipy = spline(x).flatten()
y = y.detach().numpy()
plt.plot(x,y, label="PINA", marker="o" )
plt.plot(x,y_scipy, label="SciPy", marker="x")
plt.legend()
plt.show()
ndem0
Metadata
Metadata
Assignees
Labels
No labels