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
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.
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 groupbysum
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 followwobble
, 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#1552There 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!
The text was updated successfully, but these errors were encountered: