File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,12 +8,12 @@ class Kernel:
88 """Basic kernel structure"""
99 def __init__ (self ):
1010 self ._K = None
11- self ._x , self ._y = None , None
11+ self ._x , self ._y = np . array ([ None ]), np . array ([ None ])
1212 self .dim = 0
1313
1414 def _empty_cache (self ) -> None :
1515 self ._K = None
16- self ._x , self ._y = None , None
16+ self ._x , self ._y = np . array ([ None ]), np . array ([ None ])
1717
1818 def __call__ (
1919 self ,
@@ -90,6 +90,22 @@ def d2K_dxdy(
9090 raise NotImplementedError ('The derivative of this kernel is not implemented' )
9191
9292
93+ class Trivial (Kernel ):
94+ def __init__ (self ):
95+ pass
96+
97+ def make (
98+ self ,
99+ x : np .ndarray ,
100+ y : np .ndarray ,
101+ cache = False ):
102+ """
103+ Return matrix of shape (len(x), len(y)) with entries set to 1 where
104+ x == y and 0 otherwise. Identity matrix if vectors x and y are equal.
105+ """
106+ return (x .reshape (- 1 ,1 ) == y .reshape (1 ,- 1 )).astype (float )
107+
108+
93109class RadialBasisFunction (Kernel ):
94110 """
95111 Standard Radial Basis Function (RBF) kernel, sometimes called Gaussian kernel
You can’t perform that action at this time.
0 commit comments