def rbf_kernel(X, Y=None, gamma=None):
    X, Y = check_pairwise_arrays(X, Y)
    if gamma is None:
        gamma = 1.0 / X.shape[1]

    K = euclidean_distances(X, Y, squared=True)
    K *= -gamma
    np.exp(K, K)    # exponentiate K in-place
    return K
Compute the rbf (gaussian) kernel between X and Y::
dataset/ETHPy150Open scikit-learn/scikit-learn/sklearn/metrics/pairwise.py/rbf_kernel