SheffieldML / GPy

Gaussian processes framework in python
BSD 3-Clause "New" or "Revised" License
2.04k stars 562 forks source link

Minor Issue: Python kernel dies if coregionalization is given an X with no zeroth region #566

Open lionfish0 opened 7 years ago

lionfish0 commented 7 years ago

If one enters the column of X which specifies the region without zero values, the python kernel dies. This is obviously a wrong input, but it would be nice if it failed less badly?

Example code:

import GPy
import numpy as np
X1 = np.random.rand(50)[:,None]
X2 = np.random.rand(50)[:,None]
Y1 = np.sin(X1*8.1)+np.random.randn(50,1)*0.15
Y2 = -np.sin(X2*8.1)+np.random.randn(50,1)*0.15
X1widx = np.c_[X1,np.ones(X1.shape[0])*2] #<<<<missing 0th values!
X2widx = np.c_[X2,np.ones(X2.shape[0])*1]
X = np.r_[X1widx,X2widx]
Y = np.r_[Y1,Y2]
kern = GPy.kern.RBF(1, lengthscale=80)**GPy.kern.Coregionalize(input_dim=1,output_dim=1, rank=1, active_dims=[0])
m = GPy.models.GPRegression(X,Y,kern)
m.optimize()
zhenwendai commented 7 years ago

I think it is due to the cython code for coregionalization. Maybe you can throw an exception before calling the cython code.