From 6fb7fe2352960f3d5b5ad1ccb18569ae3ebe9978 Mon Sep 17 00:00:00 2001 From: James Hensman Date: Wed, 27 Nov 2013 12:41:47 +0000 Subject: [PATCH 1/5] minor edits to the README --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 10ca8a83..a3d98466 100644 --- a/README.md +++ b/README.md @@ -22,12 +22,13 @@ For the most part, the developers are using ubuntu. To install the required pack sudo apt-get install python-numpy python-scipy python-matplotlib clone this git repository and add it to your path: - git clone git@github.com:SheffieldML/GPy.git \ - echo "PYTHONPATH=$PYTHONPATH:\ > ~/.bashrc + + git clone git@github.com:SheffieldML/GPy.git ~/gpy + echo "PYTHONPATH=$PYTHONPATH:~/gpy > ~/.bashrc Windows ------- -On windows, we recommend the ![anaconda python distribution](http://continuum.io/downloads). We've also had luck with ![enthought](http://www.enthought.com). git clone or unzip the source to a suitable directory, and add a PYTHONPATH environement variable. +On windows, we recommend the ![anaconda python distribution](http://continuum.io/downloads). We've also had luck with ![enthought](http://www.enthought.com). git clone or unzip the source to a suitable directory, and add a PYTHONPATH environment variable. OSX --- From 9231cf4bfc668e0f1aec337de913d776ef1d6373 Mon Sep 17 00:00:00 2001 From: James Hensman Date: Wed, 27 Nov 2013 13:02:24 +0000 Subject: [PATCH 2/5] more readme edits --- README.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a3d98466..5bf6e44a 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,12 @@ Getting started =============== Installing with pip ------------------- -The simplest way to install GPy is using pip. -pip install gpy +The simplest way to install GPy is using pip. ubuntu users can do: + + sudo apt-get install python-pip + pip install gpy + +If you'd like to install from source, or want to contribute to the project (e.g. by sending pull requests via github), read on. Ubuntu ------ @@ -23,8 +27,9 @@ sudo apt-get install python-numpy python-scipy python-matplotlib clone this git repository and add it to your path: - git clone git@github.com:SheffieldML/GPy.git ~/gpy - echo "PYTHONPATH=$PYTHONPATH:~/gpy > ~/.bashrc + git clone git@github.com:SheffieldML/GPy.git ~/SheffieldML + echo 'PYTHONPATH=$PYTHONPATH:~/SheffieldML' >> ~/.bashrc + Windows ------- @@ -32,8 +37,10 @@ On windows, we recommend the ![anaconda python distribution](http://continuum.io OSX --- -everything appears to work out-of-the box using ![enthought](http://www.enthought.com) on osx Mavericks. +Everything appears to work out-of-the box using ![enthought](http://www.enthought.com) on osx Mavericks. Download/clone GPy, and then add GPy to your PYTHONPATH + git clone git@github.com:SheffieldML/GPy.git ~/SheffieldML + echo 'PYTHONPATH=$PYTHONPATH:~/SheffieldML' >> ~/.profile Compiling documentation: From 36cc17cf2407604c7eb62fc001bb2fa57fa9308f Mon Sep 17 00:00:00 2001 From: James Hensman Date: Wed, 27 Nov 2013 13:09:27 +0000 Subject: [PATCH 3/5] more readme stuff --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5bf6e44a..2aada317 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,8 @@ If you'd like to install from source, or want to contribute to the project (e.g. Ubuntu ------ For the most part, the developers are using ubuntu. To install the required packages: -sudo apt-get install python-numpy python-scipy python-matplotlib + + sudo apt-get install python-numpy python-scipy python-matplotlib clone this git repository and add it to your path: @@ -33,7 +34,11 @@ clone this git repository and add it to your path: Windows ------- -On windows, we recommend the ![anaconda python distribution](http://continuum.io/downloads). We've also had luck with ![enthought](http://www.enthought.com). git clone or unzip the source to a suitable directory, and add a PYTHONPATH environment variable. +On windows, we recommend the ![anaconda python distribution](http://continuum.io/downloads). We've also had luck with ![enthought](http://www.enthought.com). git clone or unzip the source to a suitable directory, and add an approptiate PYTHONPATH environment variable. + +On windows 7 (and possibly earlier versions) there's a bug in scipy version 0.13 which tries to write very long filenmnames. Reverting to scipy 0.12 seems to do the trick: + + conda install scipy=0.12 OSX --- From 6673a8ae0218d81e5e972f025253ad073dcf8e82 Mon Sep 17 00:00:00 2001 From: James Hensman Date: Wed, 27 Nov 2013 13:10:15 +0000 Subject: [PATCH 4/5] more readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2aada317..27af0b0d 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Windows ------- On windows, we recommend the ![anaconda python distribution](http://continuum.io/downloads). We've also had luck with ![enthought](http://www.enthought.com). git clone or unzip the source to a suitable directory, and add an approptiate PYTHONPATH environment variable. -On windows 7 (and possibly earlier versions) there's a bug in scipy version 0.13 which tries to write very long filenmnames. Reverting to scipy 0.12 seems to do the trick: +On windows 7 (and possibly earlier versions) there's a bug in scipy version 0.13 which tries to write very long filenames. Reverting to scipy 0.12 seems to do the trick: conda install scipy=0.12 From db9e5314e4cdaf9a7bb18e48001b98fb0853ca82 Mon Sep 17 00:00:00 2001 From: James Hensman Date: Wed, 27 Nov 2013 13:16:18 +0000 Subject: [PATCH 5/5] removed ipdb statement from kern, cleaned up some nasty whitespace --- GPy/kern/kern.py | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/GPy/kern/kern.py b/GPy/kern/kern.py index f51c3c13..df1e3f47 100644 --- a/GPy/kern/kern.py +++ b/GPy/kern/kern.py @@ -487,12 +487,11 @@ class kern(Parameterized): p1.psi1(Z, mu, S, psi11) Mu, Sigma = p1._crossterm_mu_S(Z, mu, S) Mu, Sigma = Mu.reshape(NM,self.input_dim), Sigma.reshape(NM,self.input_dim) - + p2.psi1(Z, Mu, Sigma, psi12) eK2 = psi12.reshape(N, M, M) crossterms = eK2 * (psi11[:, :, None] + psi11[:, None, :]) target += crossterms - #import ipdb;ipdb.set_trace() else: raise NotImplementedError, "psi2 cannot be computed for this kernel" return target @@ -540,15 +539,15 @@ class kern(Parameterized): # turn around to have rbf in front p1, p2 = self.parts[i2], self.parts[i1] ps1, ps2 = self.param_slices[i2], self.param_slices[i1] - + N, M = mu.shape[0], Z.shape[0]; NM=N*M psi11 = np.zeros((N, M)) p1.psi1(Z, mu, S, psi11) - + Mu, Sigma = p1._crossterm_mu_S(Z, mu, S) Mu, Sigma = Mu.reshape(NM,self.input_dim), Sigma.reshape(NM,self.input_dim) - + tmp1 = np.zeros_like(target[ps1]) tmp2 = np.zeros_like(target[ps2]) # for n in range(N): @@ -559,7 +558,7 @@ class kern(Parameterized): # Mu, Sigma= Mu.reshape(N,M,self.input_dim), Sigma.reshape(N,M,self.input_dim) # p2.dpsi1_dtheta((dL_dpsi2[n:n+1,m:m+1,m_prime:m_prime+1]*(psi11[n:n+1,m_prime:m_prime+1]))[0], Z[m:m+1], Mu[n:n+1,m], Sigma[n:n+1,m], target[ps2]) # p2.dpsi1_dtheta((dL_dpsi2[n:n+1,m:m+1,m_prime:m_prime+1]*(psi11[n:n+1,m:m+1]))[0], Z[m_prime:m_prime+1], Mu[n:n+1, m_prime], Sigma[n:n+1, m_prime], target[ps2])#Z[m_prime:m_prime+1], Mu[n+m:(n+m)+1], Sigma[n+m:(n+m)+1], target[ps2]) - + if isinstance(p1, RBF) and isinstance(p2, RBF): psi12 = np.zeros((N, M)) p2.psi1(Z, mu, S, psi12) @@ -571,11 +570,11 @@ class kern(Parameterized): if isinstance(p1, RBF) and isinstance(p2, Linear): #import ipdb;ipdb.set_trace() pass - + p2.dpsi1_dtheta((dL_dpsi2*(psi11[:,:,None] + psi11[:,None,:])).reshape(NM,M), Z, Mu, Sigma, tmp2) - + target[ps1] += tmp1 - target[ps2] += tmp2 + target[ps2] += tmp2 else: raise NotImplementedError, "psi2 cannot be computed for this kernel" @@ -615,17 +614,17 @@ class kern(Parameterized): psi11 = np.zeros((N, M)) psi12 = np.zeros((NM, M)) #psi12_t = np.zeros((N,M)) - + p1.psi1(Z, mu, S, psi11) Mu, Sigma = p1._crossterm_mu_S(Z, mu, S) Mu, Sigma = Mu.reshape(NM,self.input_dim), Sigma.reshape(NM,self.input_dim) - + p2.psi1(Z, Mu, Sigma, psi12) tmp1 = np.zeros_like(target) p1.dpsi1_dZ((dL_dpsi2*psi12.reshape(N,M,M)).sum(1), Z, mu, S, tmp1) p1.dpsi1_dZ((dL_dpsi2*psi12.reshape(N,M,M)).sum(2), Z, mu, S, tmp1) target += tmp1 - + #p2.dpsi1_dtheta((dL_dpsi2*(psi11[:,:,None] + psi11[:,None,:])).reshape(NM,M), Z, Mu, Sigma, target) p2.dpsi1_dZ((dL_dpsi2*(psi11[:,:,None] + psi11[:,None,:])).reshape(NM,M), Z, Mu, Sigma, target) else: @@ -666,21 +665,21 @@ class kern(Parameterized): psi11 = np.zeros((N, M)) psi12 = np.zeros((NM, M)) #psi12_t = np.zeros((N,M)) - + p1.psi1(Z, mu, S, psi11) Mu, Sigma = p1._crossterm_mu_S(Z, mu, S) Mu, Sigma = Mu.reshape(NM,self.input_dim), Sigma.reshape(NM,self.input_dim) - + p2.psi1(Z, Mu, Sigma, psi12) p1.dpsi1_dmuS((dL_dpsi2*psi12.reshape(N,M,M)).sum(1), Z, mu, S, target_mu, target_S) p1.dpsi1_dmuS((dL_dpsi2*psi12.reshape(N,M,M)).sum(2), Z, mu, S, target_mu, target_S) - + #p2.dpsi1_dtheta((dL_dpsi2*(psi11[:,:,None] + psi11[:,None,:])).reshape(NM,M), Z, Mu, Sigma, target) p2.dpsi1_dmuS((dL_dpsi2*(psi11[:,:,None])).sum(1)*2, Z, Mu.reshape(N,M,self.input_dim).sum(1), Sigma.reshape(N,M,self.input_dim).sum(1), target_mu, target_S) else: raise NotImplementedError, "psi2 cannot be computed for this kernel" return target_mu, target_S - + def plot(self, x=None, plot_limits=None, which_parts='all', resolution=None, *args, **kwargs): if which_parts == 'all': which_parts = [True] * self.num_parts @@ -753,7 +752,7 @@ class Kern_check_model(Model): dL_dK = np.ones((X.shape[0], X.shape[0])) else: dL_dK = np.ones((X.shape[0], X2.shape[0])) - + self.kernel=kernel self.X = X self.X2 = X2 @@ -768,7 +767,7 @@ class Kern_check_model(Model): return False else: return True - + def _get_params(self): return self.kernel._get_params() @@ -783,7 +782,7 @@ class Kern_check_model(Model): def _log_likelihood_gradients(self): raise NotImplementedError, "This needs to be implemented to use the kern_check_model class." - + class Kern_check_dK_dtheta(Kern_check_model): """This class allows gradient checks for the gradient of a kernel with respect to parameters. """ def __init__(self, kernel=None, dL_dK=None, X=None, X2=None): @@ -798,7 +797,7 @@ class Kern_check_dKdiag_dtheta(Kern_check_model): Kern_check_model.__init__(self,kernel=kernel,dL_dK=dL_dK, X=X, X2=None) if dL_dK==None: self.dL_dK = np.ones((self.X.shape[0])) - + def log_likelihood(self): return (self.dL_dK*self.kernel.Kdiag(self.X)).sum() @@ -815,7 +814,7 @@ class Kern_check_dK_dX(Kern_check_model): def _get_param_names(self): return ['X_' +str(i) + ','+str(j) for j in range(self.X.shape[1]) for i in range(self.X.shape[0])] - + def _get_params(self): return self.X.flatten() @@ -837,7 +836,7 @@ class Kern_check_dKdiag_dX(Kern_check_model): def _get_param_names(self): return ['X_' +str(i) + ','+str(j) for j in range(self.X.shape[1]) for i in range(self.X.shape[0])] - + def _get_params(self): return self.X.flatten() @@ -863,7 +862,6 @@ def kern_test(kern, X=None, X2=None, output_ind=None, verbose=False, X_positive= if output_ind is not None: assert(output_ind