jameshensman / GPclust

Clustering time series using Gaussian processes and Variational Bayes.
GNU General Public License v3.0
39 stars 16 forks source link

global name 'N1' is not defined #11

Open FrankD opened 5 years ago

FrankD commented 5 years ago

Hi James,

Trying to use your package on some gene expression data. When I try to run your example notebook for MOHGP, I get an error at m.optimize():

NameError: global name 'N1' is not defined

Indeed looking at the code in np_utilities.py it does look like N1 is not defined, but I assume this should be working. Any ideas? Full error trace below:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-22-8066ee77b06f> in <module>()
  3 
  4 m = GPclust.MOHGP(X, k_underlying, k_corruption, Y, K=10, prior_Z='DP', alpha=1.0)
----> 5 m.optimize()
  6 m.systematic_splits(verbose=False)

/usr/local/lib/python2.7/dist-packages/GPclust-0.1.0-py2.7.egg/GPclust/collapsed_vb.pyc in optimize(self, method, maxiter, ftol, gtol, step_length, callback, verbose)
 90                 callback()
 91 
 ---> 92             grad,natgrad = self.vb_grad_natgrad()
 93             grad,natgrad = -grad,-natgrad
 94             squareNorm = np.dot(natgrad,grad) # used to monitor convergence

/usr/local/lib/python2.7/dist-packages/GPclust-0.1.0-py2.7.egg/GPclust/MOHGP.pyc in vb_grad_natgrad(self)
142         #yn_mk = self.Y[:,:,None] - self.muk[None,:,:]
143         #ynmk2 = np.sum(np.dot(self.Sy_inv, yn_mk) * np.rollaxis(yn_mk,0,2),0)
--> 144         ynmk2 = multiple_mahalanobis(self.Y, self.muk.T, self.Sy_chol)
145 
146         grad_phi = (self.mixing_prop_bound_grad() -

/usr/local/lib/python2.7/dist-packages/GPclust-0.1.0-py2.7.egg/GPclust/np_utilities.pyc in multiple_mahalanobis_numpy_loops(X1, X2, L)
 43 def multiple_mahalanobis_numpy_loops(X1, X2, L):
 44     LLT = L.dot(L.T)
---> 45     result = np.zeros(shape=(N1, N2), dtype=np.float64)
 46     n = 0
 47     while n < N1:

NameError: global name 'N1' is not defined
jameshensman commented 5 years ago

Hi @FrankD

Yes, this is a bug! Let me take a look.

j-c-love commented 4 years ago

Hi both,

I'm running into the same bug and wondered if the solution has been found?

Cheers