You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The interp1d function is unable to interpolate a 2-D tensor
For example
import torch
# Define x, y, and xnew with appropriate shapes
D, N, P = 3, 5, 4 # D = number of batches, N = original points, P = new points
# `y` is a 2D tensor with `D` rows, each representing an independent 1D function
y = torch.tensor([
[1.0, 2.0, 3.0, 4.0, 5.0],
[2.0, 3.0, 5.0, 7.0, 11.0],
[1.0, 4.0, 9.0, 16.0, 25.0]
], requires_grad=True)
# `x` is the corresponding x-coordinates, can be either 1D (shared across all `y` rows) or 2D
x = torch.tensor([0.0, 1.0, 2.0, 3.0, 4.0]) # Shape (N, )
# `xnew` is where we want the interpolated values, can be 1D or 2D
xnew = torch.tensor([0.5, 1.5, 2.5, 3.5]) # Shape (P, )
# Perform interpolation
ynew = interp1d(x, y, xnew)
print("Interpolated values (ynew):", ynew)
gives me the output Interpolated values (ynew): tensor([[1.5000, 2.5000, 3.5000, 4.5000]], grad_fn=<Interp1dBackward>)
Is this behavior expected? Or this is buggy?
The text was updated successfully, but these errors were encountered:
As per the docs said, you xnew must have the same batch size of which ever tensor is 2-D
xnew : (P,) or (D, P) Pytorch Tensor
A 1-D or 2-D tensor of real values. `xnew` can only be 1-D if
_both_ `x` and `y` are 1-D. Otherwise, its length along the first
dimension must be the same as that of whichever `x` and `y` is 2-D.
Hello,
The interp1d function is unable to interpolate a 2-D tensor
For example
gives me the output
Interpolated values (ynew): tensor([[1.5000, 2.5000, 3.5000, 4.5000]], grad_fn=<Interp1dBackward>)
Is this behavior expected? Or this is buggy?
The text was updated successfully, but these errors were encountered: