kernels.py
def kernel_matrix(self, X: Tensor, Y: Tensor = None) -> Tensor:
        """
        Computes the kernel matrix for some observation matrices X and Y.
        :param X: d x N matrix
        :param Y: d x M matrix. If not specified, it is assumed to be X.
        :return: N x M kernel matrix
        """
        if Y is None:
            Y = X
        N = X.shape[1]
        M = Y.shape[1]
        K = torch.zeros((N,M))
        for i in range(N):
            for j in range(M):
                K[i,j] = self.f(X[:,i],Y[:,j])
        return K

        Computes the kernel matrix for some observation matrices X and Y.
        :param X: d x N matrix
        :param Y: d x M matrix. If not specified, it is assumed to be X.
        :return: N x M kernel matrix
        
Computes the kernel matrix for some observation matrices X and Y.
Computes the kernel matrix for some observation matrices X and Y .
def kernel_matrix(self, X: Tensor, Y: Tensor = None) -> Tensor:
        if Y is None:
            Y = X
        N = X.shape[1]
        M = Y.shape[1]
        K = torch.zeros((N,M))
        for i in range(N):
            for j in range(M):
                K[i,j] = self.f(X[:,i],Y[:,j])
        return K
def kernel_matrix ( self , X : Tensor , Y : Tensor = None ) -> Tensor : if Y is None : Y = X N = X . shape [ 1 ] M = Y . shape [ 1 ] K = torch . zeros ( ( N , M ) ) for i in range ( N ) : for j in range ( M ) : K [ i , j ] = self . f ( X [ : , i ] , Y [ : , j ] ) return K
Computes the kernel matrix for some observation matrices X and Y.
Computes the kernel matrix for some observation matrices X and Y .
"""
        Computes the kernel matrix for some observation matrices X and Y.
        :param X: d x N matrix
        :param Y: d x M matrix. If not specified, it is assumed to be X.
        :return: N x M kernel matrix
        """
N x M kernel matrix
N x M kernel matrix
self
X
Tensor
d x N matrix
d x N matrix
Y
Tensor
d x M matrix. If not specified, it is assumed to be X.
d x M matrix . If not specified it is assumed to be X .