mattjj / pyhsmm

MIT License
550 stars 175 forks source link

negative dimensions are not allowed #80

Open szukiyu opened 7 years ago

szukiyu commented 7 years ago

I've got following error during resampling.

/// error message Traceback (most recent call last): File "hmm.py", line 150, in model.resample_model() File "/usr/lib64/python2.7/site-packages/pyhsmm-0.1.6-py2.7-linux-x86_64.egg/pyhsmm/models.py", line 459, in resample_model self.resample_parameters() File "/usr/lib64/python2.7/site-packages/pyhsmm-0.1.6-py2.7-linux-x86_64.egg/pyhsmm/models.py", line 968, in resample_parameters super(_HSMMGibbsSampling,self).resample_parameters(**kwargs) File "/usr/lib64/python2.7/site-packages/pyhsmm-0.1.6-py2.7-linux-x86_64.egg/pyhsmm/models.py", line 465, in resample_parameters self.resample_trans_distn() File "/usr/lib64/python2.7/site-packages/pyhsmm-0.1.6-py2.7-linux-x86_64.egg/pyhsmm/models.py", line 475, in resample_trans_distn self.trans_distn.resample([s.stateseq for s in self.states_list]) File "/usr/lib64/python2.7/site-packages/pyhsmm-0.1.6-py2.7-linux-x86_64.egg/pyhsmm/internals/transitions.py", line 372, in resample ms = self._get_m(trans_counts) if ms is None else ms File "/usr/lib64/python2.7/site-packages/pyhsmm-0.1.6-py2.7-linux-x86_64.egg/pyhsmm/internals/transitions.py", line 329, in _get_m m = sample_crp_tablecounts(float(self.alpha),trans_counts,self.beta) File "pyhsmm/util/cstats.pyx", line 80, in pyhsmm.util.cstats.sample_crp_tablecounts (pyhsmm/util/cstats.cpp:10384) File "mtrand.pyx", line 1143, in mtrand.RandomState.random_sample (numpy/random/mtrand/mtrand.c:13496) File "mtrand.pyx", line 163, in mtrand.cont0_array (numpy/random/mtrand/mtrand.c:1995) ValueError: negative dimensions are not allowed ///

I think I'm using sparse matrices. https://stackoverflow.com/questions/12113498/valueerror-taking-dot-product-of-two-sparse-matrices-in-scipy

Is there a way to avoid this error messages ?

szukiyu commented 7 years ago

This error occured when I used 'alpha_a_0', 'alpha_b_0', 'gamma_a_0' and 'gamma_b_0' in a definition of model of HSMM. This error does't appear when I use 'alpha' and 'gamma'.

szukiyu commented 7 years ago

Update information

The reason of this error is the trans_counts has negative value.(https://github.com/mattjj/pyhsmm/blob/master/pyhsmm/internals/transitions.py#L370)