I found an implementation of the Kernel density estimation in scikit-learn as:
from sklearn.neighbors import KernelDensity
kde = KernelDensity(bandwidth=1.0, kernel='gaussian')
kde.fit(x[:, None])
logprob = kde.score_samples(x_d[:, None])
The problem is I want to use Automatic differentiation to take the derivative of logprob w.r.t. x, so I need to use pytorch or tensorflow.
Is there any implementation of the KDE in pytorch or tensorflow, so I can use AD afterward? Or, How can I calculate the derivative of logprob w.r.t. x with scikit-learn?