diff --git a/GPy/core/parameterised.py b/GPy/core/parameterised.py index 007f1b25..b5d880a3 100644 --- a/GPy/core/parameterised.py +++ b/GPy/core/parameterised.py @@ -56,7 +56,7 @@ class parameterised(object): return copy.deepcopy(self) - def tie_param(self, which): + def tie_params(self, which): matches = self.grep_param_names(which) assert matches.size > 0, "need at least something to tie together" if len(self.tied_indices): diff --git a/GPy/examples/classification.py b/GPy/examples/classification.py index 77bd0b79..1d101d76 100644 --- a/GPy/examples/classification.py +++ b/GPy/examples/classification.py @@ -62,7 +62,7 @@ def oil(): # Contrain all parameters to be positive m.constrain_positive('') - m.tie_param('lengthscale') + m.tie_params('lengthscale') m.update_likelihood_approximation() # Optimize diff --git a/GPy/examples/tutorials.py b/GPy/examples/tutorials.py index 9d892b8e..2bc9ba60 100644 --- a/GPy/examples/tutorials.py +++ b/GPy/examples/tutorials.py @@ -138,7 +138,7 @@ def tuto_kernel_overview(): k.constrain_positive('var') k.constrain_fixed(np.array([1]),1.75) - k.tie_param('len') + k.tie_params('len') k.unconstrain('white') k.constrain_bounded('white',lower=1e-5,upper=.5) print k diff --git a/GPy/kern/kern.py b/GPy/kern/kern.py index b2970674..be45fa70 100644 --- a/GPy/kern/kern.py +++ b/GPy/kern/kern.py @@ -237,7 +237,7 @@ class kern(parameterised): for i in range(K1.Nparam + K2.Nparam): index = np.where(index_param==i)[0] if index.size > 1: - self.tie_param(index) + self.tie_params(index) for i in prev_constr_pos: self.constrain_positive(np.where(index_param==i)[0]) for i in prev_constr_neg: @@ -391,9 +391,13 @@ class kern(parameterised): target += p2.variance*(p1._psi1[:,:,None]+p1._psi1[:,None,:]) #linear X bias elif p1.name=='bias' and p2.name=='linear': - raise NotImplementedError + tmp = np.zeros((mu.shape[0],Z.shape[0])) + p2.psi1(Z,mu,S,tmp) + target += p1.variance*(tmp[:,:,None] + tmp[:,None,:]) elif p2.name=='bias' and p1.name=='linear': - raise NotImplementedError + tmp = np.zeros((mu.shape[0],Z.shape[0])) + p1.psi1(Z,mu,S,tmp) + target += p2.variance*(tmp[:,:,None] + tmp[:,None,:]) #rbf X linear elif p1.name=='linear' and p2.name=='rbf': raise NotImplementedError #TODO @@ -426,6 +430,11 @@ class kern(parameterised): elif p2.name=='bias' and p1.name=='rbf': p1.dpsi1_dtheta(dL_dpsi2.sum(1)*p2.variance*2.,Z,mu,S,target[ps1]) p2.dpsi1_dtheta(dL_dpsi2.sum(1)*p1._psi1*2.,Z,mu,S,target[ps2]) + #linear X bias + elif p1.name=='bias' and p2.name=='linear': + p2.dpsi1_dtheta(dL_dpsi2.sum(1)*p1.variance*2., Z, mu, S, target[ps1]) + elif p2.name=='bias' and p1.name=='linear': + p1.dpsi1_dtheta(dL_dpsi2.sum(1)*p2.variance*2., Z, mu, S, target[ps1]) #rbf X linear elif p1.name=='linear' and p2.name=='rbf': raise NotImplementedError #TODO @@ -451,6 +460,11 @@ class kern(parameterised): p2.dpsi1_dX(dL_dpsi2.sum(1).T*p1.variance,Z,mu,S,target) elif p2.name=='bias' and p1.name=='rbf': p1.dpsi1_dZ(dL_dpsi2.sum(1).T*p2.variance,Z,mu,S,target) + #linear X bias + elif p1.name=='bias' and p2.name=='linear': + p2.dpsi1_dZ(dL_dpsi2.sum(1).T*p1.variance, Z, mu, S, target) + elif p2.name=='bias' and p1.name=='linear': + p1.dpsi1_dZ(dL_dpsi2.sum(1).T*p2.variance, Z, mu, S, target) #rbf X linear elif p1.name=='linear' and p2.name=='rbf': raise NotImplementedError #TODO @@ -478,6 +492,11 @@ class kern(parameterised): p2.dpsi1_dmuS(dL_dpsi2.sum(1).T*p1.variance*2.,Z,mu,S,target_mu,target_S) elif p2.name=='bias' and p1.name=='rbf': p1.dpsi1_dmuS(dL_dpsi2.sum(1).T*p2.variance*2.,Z,mu,S,target_mu,target_S) + #linear X bias + elif p1.name=='bias' and p2.name=='linear': + p2.dpsi1_dmuS(dL_dpsi2.sum(1).T*p1.variance*2., Z, mu, S, target_mu, target_S) + elif p2.name=='bias' and p1.name=='linear': + p1.dpsi1_dmuS(dL_dpsi2.sum(1).T*p2.variance*2., Z, mu, S, target_mu, target_S) #rbf X linear elif p1.name=='linear' and p2.name=='rbf': raise NotImplementedError #TODO diff --git a/GPy/testing/bgplvm_tests.py b/GPy/testing/bgplvm_tests.py index dda92b90..b182c1a8 100644 --- a/GPy/testing/bgplvm_tests.py +++ b/GPy/testing/bgplvm_tests.py @@ -58,7 +58,7 @@ class BGPLVMTests(unittest.TestCase): m.randomize() self.assertTrue(m.checkgrad()) - @unittest.skip('psi2 cross terms are NotImplemented for this combination') + #@unittest.skip('psi2 cross terms are NotImplemented for this combination') def test_linear_bias_kern(self): N, M, Q, D = 10, 3, 2, 4 X = np.random.rand(N, Q) diff --git a/GPy/testing/kernel_tests.py b/GPy/testing/kernel_tests.py index bb809ea6..f1762db8 100644 --- a/GPy/testing/kernel_tests.py +++ b/GPy/testing/kernel_tests.py @@ -8,7 +8,7 @@ import GPy class KernelTests(unittest.TestCase): def test_kerneltie(self): K = GPy.kern.rbf(5, ARD=True) - K.tie_param('[01]') + K.tie_params('[01]') K.constrain_fixed('2') X = np.random.rand(5,5) Y = np.ones((5,1))