locationencoder icon indicating copy to clipboard operation
locationencoder copied to clipboard

SphericalHarmonics with legendre_polys over 30 is creating nan's

Open MrDaubinet opened this issue 1 year ago • 3 comments

This is a horrible issue and one that I can add more value to, but attempting to use the SphericalHarmonics encoder with a legendre_polys > 30 results in an NaN. Great work by the way, this stuff is awesome!

MrDaubinet avatar Jan 31 '24 21:01 MrDaubinet

Hi,

thanks for the issue and the feedback. Interesting. We started to have issues above L=50. Not yet at L=30. It may depend a bit on the float precision of the individual computers. I also noticed a small error in the analytic YLM calculations (missing brackets see this commit https://github.com/MarcCoru/locationencoder/commit/bd4dbe6fe0a3de37066e3762da67bda6664d992c) It only affects a constant within the m=0 harmonics. So, it didn't seem have a large detrimental impact on the experiments.

I fixed it today. Can you try again with the fixed constant? Maybe it will help also with higher orders. Another try could be to ensure that double precision is used. I can imagine that with low precision, some numerical instabilities can happen

MarcCoru avatar Jan 31 '24 22:01 MarcCoru

@MarcCoru thanks for the speedy response. I'll give it a go with the new commit. Worth noting that I've cast everything to a tensor of type float 64 for sanity checking and I was still getting the error. If the issue persists, I'll write up a notebook and share 😄

MrDaubinet avatar Feb 01 '24 10:02 MrDaubinet

hello, @MrDaubinet , did you solve the problem, I got nans with L=32

antonyvan avatar Apr 18 '25 10:04 antonyvan