Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1 Dimension Only? #4

Open
jeongjoonpark opened this issue Sep 6, 2020 · 3 comments
Open

1 Dimension Only? #4

jeongjoonpark opened this issue Sep 6, 2020 · 3 comments

Comments

@jeongjoonpark
Copy link

Hi I wonder if this code works for 2 or 3 dimensional data!

Thanks.

@patrick-kidger
Copy link
Owner

Depends what you mean!

The first example in the README considers three different dimensions (=channels) at the same time:

import torch
from torchcubicspline import(natural_cubic_spline_coeffs, 
                             NaturalCubicSpline)

length, channels = 7, 3
t = torch.linspace(0, 1, length)
x = torch.rand(length, channels)
coeffs = natural_cubic_spline_coeffs(t, x)
spline = NaturalCubicSpline(coeffs)
point = torch.tensor(0.4)
out = spline.evaluate(point)

If you mean that you want to have multiple "lengths", then I'm afraid not. (Good ways of doing splines isn't even a solved problem in that context.)

Does that answer your question?

@yanconglin
Copy link

yanconglin commented Dec 7, 2020

Hi, Patrick Kidger,

Thanks for sharing!
I have a similar question: interpolating on non-regular 2D/3D data.
Seems like your approach only interpolates over the time dimesion (1-D data).
Now I have a 2D non-regular grid, and want to upsample over this grid.
Since the Pytorch interploation only works with regular grids (e.g. images), I am looking for other implementations.

x = np.linspace(-3, 3, 100) # non regular grids
y = np.linspace(-5, 5, 100)
z = np.linspace(-9, 9, 100)

X,Y, Z = np.meshgrid(x,y,z,indexing='ij')
values = np.randn((100,))

interp = custom_Interp3D_algorithm((x,y,z), values)

// sample points
new_x = np.linspace(-3, 3, 400)
new_y = np.linspace(-5, 5, 400)
new_z = np.linspace(-9, 9, 400)
// output new values: [400, ]
new_values = interp((new_x, new_y, new_z))

Once can also wrap this into BXCXHXW tensor, where HX W is the 2d grid.
Was wondering if you have such an implemtation.
Thanks a lot!

Yancong

@patrick-kidger
Copy link
Owner

Hi @yanconglin - I'm afraid not, is the short answer.

Producing higher-dimensional interpolants, on irregular data, is much harder than the 1D case. Methods for doing so are much less standard than in the 1D case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants