deepsphere / deepsphere-cosmo-tf2

A spherical convolutional neural network for cosmology (TFv2).
https://arxiv.org/abs/1810.12186
MIT License
19 stars 5 forks source link

Healpy Smoothing Layer #11

Closed Arne-Thomsen closed 8 months ago

Arne-Thomsen commented 8 months ago

Based off an idea by Tomek, I've implemented a non trainable layer to smooth healpy maps in real space. The smoothing is done in the following steps:

This operation supports having multiple smoothing scales for the different channels, which are assumed to be in the last input tensor axis like (n_batch, n_pix, n_channels). To save GPU memory (the sparse kernel matrix can become quite large for large smoothing scales), the different smoothing scales are all implemented with the same sparse kernel matrix: Larger smoothing scales are achieved by smoothing repeatedly according to the rule the result of a convolution of two Gaussians with sigma_1 and sigma_2, the result is a Gaussian with sigma_3 = sqrt(sigma_1^2 + sigma_2^2). Since the number of times the smoothing is applied is restricted to integers, the layer automatically implements the closest conservative smoothing scale.

Two additional notes:

jafluri commented 8 months ago

Great, thanks a lot, looks really good.

I think the sklearn dependency is fine, since it a standard package for ML. However, is sklearn nowadays not in scikit-learn (the package name is still sklearn but the pip command uses scikit-learn)? If so, please adjust the dependency.

It would be good to keep the docstrings consistent in case we setup a proper documentation at some point.

Arne-Thomsen commented 8 months ago

Thanks for the fast response and pointing out the scikit-learn dependency, you're right. I've unified the format of the docstrings with the rest of the repo.