0
$\begingroup$

I want to implement the following Gauss kernel in Python:
enter image description here
I could implement the structure in Python up to this point. However, the last piece missing is the calculation of the parameter tau squared. How can this parameter be calculated?

import scipy as scip
from sklearn.metrics.pairwise import rbf_kernel

def gaussian_kernel(x_i, x_j):
    # ???
    tau_square = 0

    # gaussian kernel
    pairwise_sq_dists = cdist(x_i, x_j, 'sqeuclidean')
    kernel_result = scip.exp(-pairwise_sq_dists / tau_square)

    # use RBF kernel
    # gamma = ???
    # kernel_result = rbf_kernel(x_i, x_j, gamma)

    return kernel_result

Is it possible to rebuild the Gauss kernel using the existing implementation of the RBF client (User Guide) in scikit-learn? Which value would Gamma have to take then and how can it be calculated?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.