I am working on a 3D point cloud co-registration problem. I have an observed lidar point cloud and a generative model with several stochastic parameters that simulates point clouds. I am interested in using a Kernel Density Estimate generated from the observed lidar point cloud to compute the log probability of the simulated points and then optimize the generative model’s parameters to minimize the negative log likelihood from the KDE.
The sklearn KDE score_samples method is essentially what I’d like to reproduce in PyTorch as a loss function so that it can capture gradients and not just the log probability. I don’t see a straightforward way to implement KDE in PyTorch beyond building one from scratch (e.g., a list-like object containing as many 3D-Normal distributions as there are observed lidar points, which would be looped through to calculate the log_pdf for every simulated point against every one of these KDE distributions and then summing them across all distributions for all simulated points).  This seems like a lot of looping, and am not sure if there’s an effective way to broadcast this to be efficient.
Any ideas?