pmelchior / spender

Spectrum encoder and decoder
MIT License
35 stars 11 forks source link

New interp1d #38

Closed al-jshen closed 1 year ago

al-jshen commented 1 year ago

Replaces torchinterp1d with a new interp1d function in spender/util.py

The main motivation is that torchinterp1d seems to have some issues with backprop (at least on my machine, also see https://github.com/aliutkus/torchinterp1d/issues/16 and https://github.com/aliutkus/torchinterp1d/issues/17).

The new implementation also clamps at the edges instead of extrapolating.

al-jshen commented 1 year ago

This is unfortunately extremely slow compared to torchinterp1d (~100x slower on the forward pass for length 5000 tensors) and I am not too sure why. I have everything running with @torch.jit.script and I've followed this PyTorch guide to parallelize the inner loop.

pmelchior commented 1 year ago

Is it slow for single spectra or batches of spectra?

al-jshen commented 1 year ago

Both.

Ashkan13776 commented 1 year ago

Hi @al-jshen. How can I make this faster? Thanks!