How to calculate a Gaussian kernel matrix efficiently in numpy?

def GaussianMatrix(X,sigma): row,col=X.shape GassMatrix=np.zeros(shape=(row,row)) X=np.asarray(X) i=0 for v_i in X: j=0 for v_j in X: GassMatrix[i,j]=Gaussian(v_i.T,v_j.T,sigma) j+=1 i+=1 return GassMatrix def Gaussian(x,z,sigma): return np.exp((-(np.linalg.norm(x-z)**2))/(2*sigma**2)) This is my current way. Is there any way I can use matrix operation to do this? X is the data points. Answers: Thank you for visiting the Q&A section on … Read more