mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-10 20:42:39 +02:00
posterior with one covariance per dimension and param gradient fix
This commit is contained in:
parent
46f59f9f64
commit
52ab456bfe
3 changed files with 9 additions and 4 deletions
|
|
@ -86,6 +86,9 @@ class Param(ObservableArray, Constrainable, Gradcheckable, Indexable, Parentable
|
||||||
if self._gradient_ is None:
|
if self._gradient_ is None:
|
||||||
self._gradient_ = numpy.zeros(self._realshape_)
|
self._gradient_ = numpy.zeros(self._realshape_)
|
||||||
return self._gradient_
|
return self._gradient_
|
||||||
|
@gradient.setter
|
||||||
|
def gradient(self, val):
|
||||||
|
self.gradient[:] = val
|
||||||
|
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
# Pickling operations
|
# Pickling operations
|
||||||
|
|
|
||||||
|
|
@ -81,13 +81,16 @@ class Posterior(object):
|
||||||
def covariance(self):
|
def covariance(self):
|
||||||
if self._covariance is None:
|
if self._covariance is None:
|
||||||
#LiK, _ = dtrtrs(self.woodbury_chol, self._K, lower=1)
|
#LiK, _ = dtrtrs(self.woodbury_chol, self._K, lower=1)
|
||||||
self._covariance = self._K - self._K.dot(self.woodbury_inv).dot(self._K)
|
self._covariance = np.tensordot(np.dot(np.atleast_3d(self.woodbury_inv).T, self._K), self._K, [1,0]).T
|
||||||
|
#self._covariance = self._K - self._K.dot(self.woodbury_inv).dot(self._K)
|
||||||
return self._covariance
|
return self._covariance
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def precision(self):
|
def precision(self):
|
||||||
if self._precision is None:
|
if self._precision is None:
|
||||||
self._precision, _, _, _ = pdinv(self.covariance)
|
self._precision = np.zeros(np.atleast_3d(self.covariance).shape) # if one covariance per dimension
|
||||||
|
for p in xrange(self.covariance.shape[-1]):
|
||||||
|
self._precision[:,:,p] = pdinv(self.covariance[:,:,p])[0]
|
||||||
return self._precision
|
return self._precision
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@
|
||||||
|
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import scipy as sp
|
|
||||||
import pylab as plt
|
|
||||||
|
|
||||||
class WarpingFunction(object):
|
class WarpingFunction(object):
|
||||||
"""
|
"""
|
||||||
|
|
@ -39,6 +37,7 @@ class WarpingFunction(object):
|
||||||
def plot(self, psi, xmin, xmax):
|
def plot(self, psi, xmin, xmax):
|
||||||
y = np.arange(xmin, xmax, 0.01)
|
y = np.arange(xmin, xmax, 0.01)
|
||||||
f_y = self.f(y, psi)
|
f_y = self.f(y, psi)
|
||||||
|
from matplotlib import pyplot as plt
|
||||||
plt.figure()
|
plt.figure()
|
||||||
plt.plot(y, f_y)
|
plt.plot(y, f_y)
|
||||||
plt.xlabel('y')
|
plt.xlabel('y')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue