MarcCoru / locationencoder

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SphericalHarmonics with legendre_polys over 30 is creating nan's

MrDaubinet opened this issue · 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!

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 bd4dbe6)
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 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 😄