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

Radial Velocity needs to be able to "sense" backpropagation-- implement interpolation from native models instead of resampling #1

Closed
gully opened this issue Dec 1, 2020 · 0 comments

Comments

@gully
Copy link
Owner

gully commented Dec 1, 2020

Currently we shift the wavelength grid with the scalar radial velocity (a nn.Parameter that requires grad), and then simply use the data's wavelength grid to define the boundaries for conducting a groupby sum operation. This sequence of steps is not "backprop"-able---- how do you take the derivative of boundaries. In other words, for this operation to work as intended, backprop would have to somehow decide which model indices would have moved into adjacent bins given different choices for RV. That's not something that a derivative alone can answer, and so the message-passing aspect of backprop will fail. Instead, we should follow wobble, and use an interpolation scheme. The problem is that wobble implemented their own interpolation, because apparently TensorFlow didn't have one at the time. In any case, pytorch does not support irregularly sampled interpolation, although a feature request for it has existed for a few years: pytorch/pytorch#1552

There are a few ways to get around this:

1. Use a Gaussian Process mean posterior model.

Train a GP on the synthetic spectrum at native or near-native resolution (it doesn't even have to be right, just close, in fact some smoothing is desired). Then compute the mean model, evaluated at the RV-shifted data grid points. This approach should work, since everything is matrix multiplies and solves, and it should be fine to back-prop through all that like a normal GP. The demerits are: 1) it'll be "slow" since you have to make a GP on ~20,000 points (that's OK on GPU actually!), we'd probably have to code it up, exactly, ourselves, since at first sight, it looks wants to separate train and eval steps for the mean posterior evaluation. So while it would work, and might even be preferable, there some roadblocks that make this a backup or rainy day option. By the way, this idea is similar in spirit to the psoap framework.

2. Find a way to do interpolation with PyTorch

This is probably the easiest way forward. There's at least one third party tool that seems to work:
https://github.com/aliutkus/torchinterp1d

Let's pursue option 2 for now!

@gully gully closed this as completed in 9849f42 Dec 2, 2020
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

1 participant