Permalink
Browse files

extra testing

  • Loading branch information...
1 parent 4525c18 commit 230985d8165b28a83fd0069d388d52cfeb58e434 @andrewcron committed Jul 27, 2012
Showing with 26 additions and 6 deletions.
  1. +5 −1 src/dpmix.py
  2. +1 −0 src/utils.py
  3. +2 −1 tests/test_bounds.py
  4. +4 −4 tests/test_dpmix.py
  5. +14 −0 tests/test_ident.py
View
@@ -251,7 +251,11 @@ def sample(self, niter=1000, nburn=0, thin=1, ident=False):
## relabel if needed:
if i>0 and ident:
cost = c0.copy()
- _get_cost(zref, zhat, cost) #cython!!
+ try:
+ _get_cost(zref, zhat, cost) #cython!!
+ except IndexError:
+ print 'Something stranged happened ... do zref and zhat look correct?'
+ import pdb; pdb.set_trace()
_, iii = np.where(munkres(cost))
weights = weights[iii]
mu = mu[iii]
View
@@ -33,6 +33,7 @@ def _get_cost(x,y,C):
for i in range(n):
C[x[i], y[i]] -= 1
+
def mvn_weighted_logged(data, means, covs, weights):
n, p = data.shape
k = len(weights)
@@ -1,6 +1,7 @@
import numpy.random as npr
from dpmix import HDPNormalMixture
+
if __name__ == '__main__':
nclust = 256
niter = 10
@@ -10,7 +11,7 @@
num_files = 10
seed = 9
- npr.seed(seed)
+ #npr.seed(seed)
xs = []
for i in range(num_files):
View
@@ -6,15 +6,15 @@
'''
import sys
#sys.path.insert(0, '../build/lib.linux-x86_64-2.7/')
-sys.path.insert(0, "../src")
+#sys.path.insert(0, "../src")
import numpy as np
import numpy.random as npr
import pymc as pm
#
-from dpmix import DPNormalMixture
-from BEM import BEM_DPNormalMixture
-#from dpmix import DPNormalMixture, BEM_DPNormalMixture
+#from dpmix import DPNormalMixture
+#from BEM import BEM_DPNormalMixture
+from dpmix import DPNormalMixture, BEM_DPNormalMixture
#import gpustats as gs
View
@@ -0,0 +1,14 @@
+#import sys
+#sys.path.insert(0, "../src")
+
+import numpy.random as npr
+import dpmix
+
+if __name__ == "__main__":
+ xs = npr.random((2,100,2))
+ for x in xs:
+ m1 = dpmix.DPNormalMixture(x, ncomp=128, gpu=2, verbose=10)
+ m1.sample(100, nburn=0)
+
+ m2 = dpmix.DPNormalMixture(m1, verbose=10)
+ m2.sample(10, nburn=0, ident=True)

0 comments on commit 230985d

Please sign in to comment.