mnnpy icon indicating copy to clipboard operation
mnnpy copied to clipboard

Is Gaussian kernel being calculated correctly?

Open dylkot opened this issue 6 years ago • 0 comments

Hi, thank you for implementing this algorithm in Python! Also please forgive me if I am making an obvious mistake here. But I am wondering whether the correction_vectors are being calculated correctly. I am wondering why kdist is being calculated with a dot product rather than with a Euclidean distance

@jit(float32[:, :](float32[:, :], float32[:, :]))
def kdist(m, n):
    dist = np.zeros((m.shape[0], n.shape[0]), dtype=np.float32)
    for i in range(m.shape[0]):
        for j in range(n.shape[0]):
            dist[i, j] = np.dot(m[i], n[j])
    return dist

shouldn't this be

dist[i, j]  =  np.sum((m[i]-n[j])**2)

for exp_distance to be the Gaussian kernel? I get that taking the dot product would be the same as computing the cosine similarity if we assume that m[i] and n[j] have been L1 normalized. But we can be computing correction vectors on ref_batch_out and new_batch_out which aren't necessarily L1 normalized. And I also don't think this is the correct expression for a Gaussian kernel either way.

Thanks for your attention and sorry again if I am making a mistake here. Unfortunately the math of the Gaussian kernel smoothing does not seem to be described in the manuscript.

dylkot avatar Mar 27 '19 23:03 dylkot