mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-21 14:05:14 +02:00
kerns
This commit is contained in:
parent
e7a9a6a2fa
commit
63321e8409
18 changed files with 1861 additions and 0 deletions
47
GPy/kern/bias.py
Normal file
47
GPy/kern/bias.py
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
from kernpart import kernpart
|
||||
import numpy as np
|
||||
import hashlib
|
||||
|
||||
class bias(kernpart):
|
||||
def __init__(self,D,variance=1.):
|
||||
"""
|
||||
Arguments
|
||||
----------
|
||||
D: int - the number of input dimensions
|
||||
variance: float
|
||||
"""
|
||||
self.D = D
|
||||
self.Nparam = 1
|
||||
self.name = 'bias'
|
||||
self.set_param(np.array([variance]).flatten())
|
||||
|
||||
def get_param(self):
|
||||
return self.variance
|
||||
|
||||
def set_param(self,x):
|
||||
assert x.shape==(1,)
|
||||
self.variance = x
|
||||
|
||||
def get_param_names(self):
|
||||
return ['variance']
|
||||
|
||||
def K(self,X,X2,target):
|
||||
if X2 is None: X2 = X
|
||||
np.add(self.variance, target,target)
|
||||
|
||||
def Kdiag(self,X,target):
|
||||
np.add(target,self.variance,target)
|
||||
|
||||
def dK_dtheta(self,X,X2,target):
|
||||
"""Return shape is NxMx(Ntheta)"""
|
||||
if X2 is None: X2 = X
|
||||
np.add(target[:,:,0],1., target[:,:,0])
|
||||
|
||||
def dKdiag_dtheta(self,X,target):
|
||||
np.add(target[:,0],1.,target[:,0])
|
||||
|
||||
def dK_dX(self, X, X2, target):
|
||||
pass
|
||||
|
||||
def dKdiag_dX(self,X,target):
|
||||
pass
|
||||
Loading…
Add table
Add a link
Reference in a new issue