dattalab / pyhsmm-library-models

library models built on top of pyhsmm
0 stars 1 forks source link

Unable to train SubHMMs with size larger than Nmaxsuper=65 #47

Closed alexbw closed 10 years ago

alexbw commented 11 years ago

I keep bumping into a segmentation fault on Orchestra, SEAS and Jefferson.

It occurs all of a sudden — memory does not creep up, but the program crashes before resampling.

I have a stacktrace, but I have no experience reading these things, so I have no idea if it's useful. I'm going to keep digging with print statements to see the source.

#0  compiled_func (self=<value optimized out>, args=<value optimized out>)
    at /tmp/85855_python27_compiled/sc_8eb3b038d5d04a86adc1944dc577fca10.cpp:723
#1  0x00002aaaaad11b78 in PyObject_Call (func=0x2cf5c20, arg=0x2f375f0, kw=0x0) at Objects/abstract.c:2529
#2  0x00002aaaaadb3126 in PyEval_CallObjectWithKeywords (func=0x2cf5c20, arg=0x2f375f0, kw=0x0) at Python/ceval.c:3890
#3  0x00002aaaaadb298c in builtin_apply (self=<value optimized out>, args=<value optimized out>) at Python/bltinmodule.c:201
#4  0x00002aaaaadba299 in call_function (f=0x39b1c50, throwflag=<value optimized out>) at Python/ceval.c:4021
#5  PyEval_EvalFrameEx (f=0x39b1c50, throwflag=<value optimized out>) at Python/ceval.c:2666
#6  0x00002aaaaadbbba9 in PyEval_EvalCodeEx (co=0x29c4130, globals=<value optimized out>, locals=<value optimized out>,
    args=0x3a0c018, argcount=3, kws=0x3a0c030, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3253
#7  0x00002aaaaadb9955 in call_function (f=0x3a0be00, throwflag=<value optimized out>) at Python/ceval.c:4117
#8  PyEval_EvalFrameEx (f=0x3a0be00, throwflag=<value optimized out>) at Python/ceval.c:2666
#9  0x00002aaaaadbbba9 in PyEval_EvalCodeEx (co=0x29c4430, globals=<value optimized out>, locals=<value optimized out>, args=0xd,
    argcount=2, kws=0x3c5b2a8, kwcount=3, defs=0x2bee528, defcount=12, closure=0x0) at Python/ceval.c:3253
#10 0x00002aaaaadb9955 in call_function (f=0x3c5b0f0, throwflag=<value optimized out>) at Python/ceval.c:4117
#11 PyEval_EvalFrameEx (f=0x3c5b0f0, throwflag=<value optimized out>) at Python/ceval.c:2666
#12 0x00002aaaaadbbba9 in PyEval_EvalCodeEx (co=0x2dfc3b0, globals=<value optimized out>, locals=<value optimized out>, args=0x3,
    argcount=0, kws=0x34b8958, kwcount=3, defs=0x2df8428, defcount=1, closure=0x0) at Python/ceval.c:3253
#13 0x00002aaaaadb9955 in call_function (f=0x34b87d0, throwflag=<value optimized out>) at Python/ceval.c:4117
#14 PyEval_EvalFrameEx (f=0x34b87d0, throwflag=<value optimized out>) at Python/ceval.c:2666
#15 0x00002aaaaadbbba9 in PyEval_EvalCodeEx (co=0x2e09c30, globals=<value optimized out>, locals=<value optimized out>,
    args=0x2f3bd28, argcount=1, kws=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3253
#16 0x00002aaaaad3fa62 in function_call (func=0x2e42f50, arg=0x2f3bd10, kw=0x0) at Objects/funcobject.c:526
#17 0x00002aaaaad11b78 in PyObject_Call (func=0x2e42f50, arg=0x2f3bd10, kw=0x0) at Objects/abstract.c:2529
#18 0x00002aaaaad2222f in instancemethod_call (func=<value optimized out>, arg=0x2f3bd10, kw=0x0) at Objects/classobject.c:2602
#19 0x00002aaaaad11b78 in PyObject_Call (func=0x2f5f1e0, arg=0x2f3bd10, kw=0x0) at Objects/abstract.c:2529
#20 0x00002aaaaadb4f42 in call_function (f=0x34b8600, throwflag=<value optimized out>) at Python/ceval.c:4239
#21 PyEval_EvalFrameEx (f=0x34b8600, throwflag=<value optimized out>) at Python/ceval.c:2666
#22 0x00002aaaaadbade8 in call_function (f=0x34b7b10, throwflag=<value optimized out>) at Python/ceval.c:4107
#23 PyEval_EvalFrameEx (f=0x34b7b10, throwflag=<value optimized out>) at Python/ceval.c:2666
#24 0x00002aaaaadbbba9 in PyEval_EvalCodeEx (co=0x2cfdd30, globals=<value optimized out>, locals=<value optimized out>, args=0x6,
    argcount=2, kws=0x2f27900, kwcount=2, defs=0x2e0ec18, defcount=4, closure=0x0) at Python/ceval.c:3253
#25 0x00002aaaaad3fa62 in function_call (func=0x2e0da28, arg=0x2f097a0, kw=0x2aaac4051640) at Objects/funcobject.c:526
#26 0x00002aaaaad11b78 in PyObject_Call (func=0x2e0da28, arg=0x2f097a0, kw=0x2aaac4051640) at Objects/abstract.c:2529
#27 0x00002aaaaadb7535 in ext_do_call (f=0x34b75f0, throwflag=<value optimized out>) at Python/ceval.c:4334
#28 PyEval_EvalFrameEx (f=0x34b75f0, throwflag=<value optimized out>) at Python/ceval.c:2705
#29 0x00002aaaaadbbba9 in PyEval_EvalCodeEx (co=0x2e0f330, globals=<value optimized out>, locals=<value optimized out>, args=0x6,
    argcount=2, kws=0x2f22750, kwcount=5, defs=0x2e0ef30, defcount=4, closure=0x0) at Python/ceval.c:3253
#30 0x00002aaaaad3fa62 in function_call (func=0x2e44668, arg=0x2f09758, kw=0x2aaac4063da0) at Objects/funcobject.c:526
#31 0x00002aaaaad11b78 in PyObject_Call (func=0x2e44668, arg=0x2f09758, kw=0x2aaac4063da0) at Objects/abstract.c:2529
#32 0x00002aaaaad2222f in instancemethod_call (func=<value optimized out>, arg=0x2f09758, kw=0x2aaac4063da0)
    at Objects/classobject.c:2602
#33 0x00002aaaaad11b78 in PyObject_Call (func=0x2f5f280, arg=0x2f09758, kw=0x2aaac4063da0) at Objects/abstract.c:2529
#34 0x00002aaaaadb7535 in ext_do_call (f=0x34b7210, throwflag=<value optimized out>) at Python/ceval.c:4334
#35 PyEval_EvalFrameEx (f=0x34b7210, throwflag=<value optimized out>) at Python/ceval.c:2705
#36 0x00002aaaaadbbba9 in PyEval_EvalCodeEx (co=0x2e14230, globals=<value optimized out>, locals=<value optimized out>,
    args=0x2aaaabe894b0, argcount=2, kws=0x2f220f0, kwcount=5, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3253
#37 0x00002aaaaad3fa62 in function_call (func=0x2e455f0, arg=0x2f233b0, kw=0x2aaac407b0c0) at Objects/funcobject.c:526
#38 0x00002aaaaad11b78 in PyObject_Call (func=0x2e455f0, arg=0x2f233b0, kw=0x2aaac407b0c0) at Objects/abstract.c:2529
#39 0x00002aaaaadb7535 in ext_do_call (f=0x34b7020, throwflag=<value optimized out>) at Python/ceval.c:4334
#40 PyEval_EvalFrameEx (f=0x34b7020, throwflag=<value optimized out>) at Python/ceval.c:2705
#41 0x00002aaaaadbbba9 in PyEval_EvalCodeEx (co=0x2e189b0, globals=<value optimized out>, locals=<value optimized out>, args=0x2,
    argcount=1, kws=0x2f6f788, kwcount=6, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3253
#42 0x00002aaaaad3fa62 in function_call (func=0x2e48cf8, arg=0x2f15350, kw=0x2aaac405c920) at Objects/funcobject.c:526
#43 0x00002aaaaad11b78 in PyObject_Call (func=0x2e48cf8, arg=0x2f15350, kw=0x2aaac405c920) at Objects/abstract.c:2529
#44 0x00002aaaaadb7535 in ext_do_call (f=0x382ac00, throwflag=<value optimized out>) at Python/ceval.c:4334
#45 PyEval_EvalFrameEx (f=0x382ac00, throwflag=<value optimized out>) at Python/ceval.c:2705
#46 0x00002aaaaadbbba9 in PyEval_EvalCodeEx (co=0x2ceba30, globals=<value optimized out>, locals=<value optimized out>, args=0x4,
    argcount=1, kws=0x2f6f820, kwcount=6, defs=0x2e5daa8, defcount=1, closure=0x0) at Python/ceval.c:3253
#47 0x00002aaaaad3fa62 in function_call (func=0x2e612a8, arg=0x2ce6a90, kw=0x2aaac4063b60) at Objects/funcobject.c:526
#48 0x00002aaaaad11b78 in PyObject_Call (func=0x2e612a8, arg=0x2ce6a90, kw=0x2aaac4063b60) at Objects/abstract.c:2529
#49 0x00002aaaaad2222f in instancemethod_call (func=<value optimized out>, arg=0x2ce6a90, kw=0x2aaac4063b60)
    at Objects/classobject.c:2602
#50 0x00002aaaaad11b78 in PyObject_Call (func=0x2aaaa50, arg=0x2aaaaba44050, kw=0x2aaac4063b60) at Objects/abstract.c:2529
#51 0x00002aaaaad7483c in slot_tp_init (self=<value optimized out>, args=0x2aaaaba44050, kwds=0x2aaac4063b60)
    at Objects/typeobject.c:5692
#52 0x00002aaaaad6e778 in type_call (type=<value optimized out>, args=0x2aaaaba44050, kwds=0x2aaac4063b60) at Objects/typeobject.c:743
#53 0x00002aaaaad11b78 in PyObject_Call (func=0x2e848f0, arg=0x2aaaaba44050, kw=0x2aaac4063b60) at Objects/abstract.c:2529
#54 0x00002aaaaadb7535 in ext_do_call (f=0x3bfaac0, throwflag=<value optimized out>) at Python/ceval.c:4334
#55 PyEval_EvalFrameEx (f=0x3bfaac0, throwflag=<value optimized out>) at Python/ceval.c:2705
#56 0x00002aaaaadbbba9 in PyEval_EvalCodeEx (co=0x2cfaab0, globals=<value optimized out>, locals=<value optimized out>, args=0x6,
    argcount=1, kws=0x2e60cc8, kwcount=2, defs=0x2e49bc0, defcount=4, closure=0x0) at Python/ceval.c:3253
#57 0x00002aaaaad3fa62 in function_call (func=0x2e58b90, arg=0x2f05f10, kw=0x394fe40) at Objects/funcobject.c:526
#58 0x00002aaaaad11b78 in PyObject_Call (func=0x2e58b90, arg=0x2f05f10, kw=0x394fe40) at Objects/abstract.c:2529
#59 0x00002aaaaadb7535 in ext_do_call (f=0x2aaac4053000, throwflag=<value optimized out>) at Python/ceval.c:4334
#60 PyEval_EvalFrameEx (f=0x2aaac4053000, throwflag=<value optimized out>) at Python/ceval.c:2705
#61 0x00002aaaaadbbba9 in PyEval_EvalCodeEx (co=0x2cebc30, globals=<value optimized out>, locals=<value optimized out>,
    args=0x2aaaabe971f0, argcount=2, kws=0x6cd4a0, kwcount=1, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3253
#62 0x00002aaaaadb9955 in call_function (f=0x6cd310, throwflag=<value optimized out>) at Python/ceval.c:4117
#63 PyEval_EvalFrameEx (f=0x6cd310, throwflag=<value optimized out>) at Python/ceval.c:2666
#64 0x00002aaaaadbbba9 in PyEval_EvalCodeEx (co=0x2aaaabbc8ab0, globals=<value optimized out>, locals=<value optimized out>,
    args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3253
#65 0x00002aaaaadbbc22 in PyEval_EvalCode (co=0x2aaaaba3b4c0, globals=0x3, locals=0x0) at Python/ceval.c:667
#66 0x00002aaaaaddf2e1 in run_mod (fp=0x6dfc20, filename=0x7fffffffdc4e "real_data_plots/parallel-library-subhmms.py",
    start=<value optimized out>, globals=0x63e690, locals=0x63e690, closeit=1, flags=0x7fffffffd670) at Python/pythonrun.c:1365
#67 PyRun_FileExFlags (fp=0x6dfc20, filename=0x7fffffffdc4e "real_data_plots/parallel-library-subhmms.py",
    start=<value optimized out>, globals=0x63e690, locals=0x63e690, closeit=1, flags=0x7fffffffd670) at Python/pythonrun.c:1351
#68 0x00002aaaaaddf587 in PyRun_SimpleFileExFlags (fp=<value optimized out>,
    filename=0x7fffffffdc4e "real_data_plots/parallel-library-subhmms.py", closeit=1, flags=0x7fffffffd670) at Python/pythonrun.c:943
#69 0x00002aaaaadf1d46 in Py_Main (argc=<value optimized out>, argv=0x7fffffffd798) at Modules/main.c:641
#70 0x00002aaaab6fec4d in __libc_start_main (main=<value optimized out>, argc=<value optimized out>, ubp_av=<value optimized out>,
    init=<value optimized out>, fini=<value optimized out>, rtld_fini=<value optimized out>, stack_end=0x7fffffffd788)
    at libc-start.c:228
mattjj commented 11 years ago

Wow, that's inside some weave'd code (hence the python27_compiled directory). I don't see anything in this trace that can tell us in what weave'd function the segfault happened.

It crashes before entering the resampling loop? Any more info on where exactly it might be dying? I can make some guesses but it'd be good to narrow it down.

(Maybe a stack array gets too big...)

alexbw commented 11 years ago

Found the line. It's in sample_markov() in stats.py. My gut says there's an off-by-one here, but I will have to experiment.

(gdb) l
718                             i++
719                             ) ;
720                         out[0] = i;
721
722                         for (int t=1; t<T; t++) {
723                             for (
724                                 i=0,val=((float)rand())/RAND_MAX;
725                                 i < N-1 && (val -= trans_matrix[N*out[t-1]+i]) > 1e-6;
726                                 i++
727                                 ) ;
alexbw commented 11 years ago

Did you ever think you'd see the day when your transition matrices would be so big that you couldn't index them with 32-bit integers? Today's the day.

mattjj commented 11 years ago

That was my guess for which method it would be.

That matrix is more than 4GB? Wow... I need to write a special forward sampling function for that... (in addition to the backwards posterior sampling function I wrote with sparse matrices that now needs faster sparse matrices).

mattjj commented 11 years ago

Err that'd be indexing with an unsigned int, I guess it's about 2GB right now.

alexbw commented 11 years ago

For the sake of the log, the trans_matrix is 2766760000 elements, 10.3GB. Big.

alexbw commented 10 years ago

I'm on the new dev branch, with sparse matrices that will fit into memory. I'm getting the following error when running the parallel-library-subhmm.py test. library-subhmm.py works, though.

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)<string> in <module>()
/home/abw11/Code/pyhsmm_library_models/pyhsmm/parallel.py in _call(f, data_id, **kwargs)
     86     @engine_global_namespace
     87     def _call(f,data_id,**kwargs):
---> 88         return f(my_data[data_id],**kwargs)
     89
     90     if engine_globals is not None:
/home/abw11/Code/pyhsmm_library_models/library_subhmm_models.py in _state_sampler(frozen_aBl, **kwargs)
    117                 data=frozen_aBl, # dummy
    118                 frozen_aBl=frozen_aBl,
--> 119                 initialize_from_prior=False,temp=temp,**kwargs)
    120         like = global_model.states_list[-1].log_likelihood()
    121         big_stateseq = global_model.states_list.pop().big_stateseq
/home/abw11/Code/pyhsmm_library_models/pyhsmm/models.pyc in add_data(self, data, stateseq, trunc, right_censoring, left_censoring, **kwargs)
    457             left_censoring=left_censoring,
    458             trunc=trunc,
--> 459             **kwargs))
    460
    461     ### generation
/home/abw11/Code/pyhsmm_library_models/library_subhmm_models.pyc in __init__(self, model, data, frozen_aBl, **kwargs)
     37             self._frozen_aBls = [frozen_aBl] * self.hsmm_trans_matrix.shape[0]
     38         super(HSMMIntNegBinVariantFrozenSubHMMsStates,self).__init__(
---> 39                 model=model,data=data,**kwargs)
     40
     41     # TODO compute likelihoods lazily? push this into aBls? why'd I break it
/home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in __init__(self, model, *args, **kwargs)
   1119     def __init__(self,model,*args,**kwargs):
   1120         self.model = model
-> 1121         super(HSMMIntNegBinVariantSubHMMsStates,self).__init__(model,*args,**kwargs)
   1122         self.data = self.data.astype('float32',copy=False) if self.data is not None else None
   1123         self._alphan = None
/home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in __init__(self, *args, **kwargs)
    735
    736     def __init__(self,*args,**kwargs):
--> 737         HSMMStatesPython.__init__(self,*args,**kwargs)
    738
    739     def clear_caches(self):
/home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in __init__(self, model, right_censoring, left_censoring, trunc, stateseq, **kwargs)
    449         self.trunc = trunc
    450
--> 451         super(HSMMStatesPython,self).__init__(model,stateseq=stateseq,**kwargs)
    452
    453     def _get_stateseq(self):
/home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in __init__(self, model, T, data, stateseq, initialize_from_prior, **kwargs)
     31         else:
     32             if data is not None and not initialize_from_prior:
---> 33                 self.resample(**kwargs)
     34             else:
     35                 self.generate_states()
/home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in resample(self, temp)
   1343     def resample(self,temp=None):
   1344         # TODO something with temperature
-> 1345         self._remove_substates_from_subHMMs()
   1346         alphan = self.messages_forwards_normalized()
   1347         self.sample_backwards_normalized(alphan)
/home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in _remove_substates_from_subHMMs(self)
   1355
   1356     def _remove_substates_from_subHMMs(self):
-> 1357         for superstate, states_obj in zip(self.stateseq_norep, self.substates_list):
   1358             self.model.HMMs[superstate].states_list.remove(states_obj)
   1359         self.substates_list = []
/home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in stateseq_norep(self)
    463     @property
    464     def stateseq_norep(self):
--> 465         if self._stateseq_norep is None:
    466             self._stateseq_norep, self._durations_censored = rle(self.stateseq)
    467         return self._stateseq_norep
AttributeError: 'HSMMIntNegBinVariantFrozenSubHMMsStates' object has no attribute '_stateseq_norep'
mattjj commented 10 years ago

Btw you can just add a hasattr check there if you want. It should be set to None on object initialization, but that bit must have been lost in one of my changes. Checking hasattr is an easy local fix.

So to the start of the condition add

not hasattr(self,'_stateseq_norep') or ...

Matt

Sent from my phone

On Nov 6, 2013, at 10:01 AM, Alex Wiltschko notifications@github.com wrote:

I'm on the new dev branch, with sparse matrices that will fit into memory. I'm getting the following error when running the parallel-library-subhmm.py test. library-subhmm.py works, though.


AttributeError Traceback (most recent call last) in () /home/abw11/Code/pyhsmm_library_models/pyhsmm/parallel.py in _call(f, data_id, kwargs) 86 @engine_global_namespace 87 def _call(f,data_id,kwargs): ---> 88 return f(my_data[data_id],kwargs) 89 90 if engine_globals is not None: /home/abw11/Code/pyhsmm_library_models/library_subhmm_models.py in _state_sampler(frozen_aBl, kwargs) 117 data=frozen_aBl, # dummy 118 frozen_aBl=frozen_aBl, --> 119 initialize_from_prior=False,temp=temp,kwargs) 120 like = global_model.states_list[-1].log_likelihood() 121 big_stateseq = global_model.states_list.pop().big_stateseq /home/abw11/Code/pyhsmm_library_models/pyhsmm/models.pyc in add_data(self, data, stateseq, trunc, right_censoring, left_censoring, _kwargs) 457 left_censoring=left_censoring, 458 trunc=trunc, --> 459 _kwargs)) 460 461 ### generation /home/abw11/Code/pyhsmm_library_models/library_subhmm_models.pyc in init(self, model, data, frozen_aBl, kwargs) 37 self._frozen_aBls = [frozen_aBl] * self.hsmm_trans_matrix.shape[0] 38 super(HSMMIntNegBinVariantFrozenSubHMMsStates,self).init( ---> 39 model=model,data=data,kwargs) 40 41 # TODO compute likelihoods lazily? push this into aBls? why'd I break it /home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in init(self, model, _args, *_kwargs) 1119 def init(self,model,_args,kwargs): 1120 self.model = model -> 1121 super(HSMMIntNegBinVariantSubHMMsStates,self).init(model,_args,**kwargs) 1122 self.data = self.data.astype('float32',copy=False) if self.data is not None else None 1123 self._alphan = None /home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in init__(self, _args, *_kwargs) 735 736 def init(self,*args,kwargs): --> 737 HSMMStatesPython.init(self,_args,__kwargs) 738 739 def clear_caches(self): /home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in init*(self, model, right_censoring, left_censoring, trunc, stateseq, _kwargs) 449 self.trunc = trunc 450 --> 451 super(HSMMStatesPython,self).init(model,stateseq=stateseq,kwargs) 452 453 def _get_stateseq(self): /home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in init(self, model, T, data, stateseq, initialize_from_prior, kwargs) 31 else: 32 if data is not None and not initialize_from_prior: ---> 33 self.resample(kwargs) 34 else: 35 self.generate_states() /home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in resample(self, temp) 1343 def resample(self,temp=None): 1344 # TODO something with temperature -> 1345 self._remove_substates_from_subHMMs() 1346 alphan = self.messages_forwards_normalized() 1347 self.sample_backwards_normalized(alphan) /home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in _remove_substates_from_subHMMs(self) 1355 1356 def _remove_substates_from_subHMMs(self): -> 1357 for superstate, states_obj in zip(self.stateseq_norep, self.substates_list): 1358 self.model.HMMs[superstate].states_list.remove(states_obj) 1359 self.substates_list = [] /home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in stateseq_norep(self) 463 @property 464 def stateseq_norep(self): --> 465 if self._stateseq_norep is None: 466 self._stateseq_norep, self._durations_censored = rle(self.stateseq) 467 return self._stateseq_norep AttributeError: 'HSMMIntNegBinVariantFrozenSubHMMsStates' object has no attribute '_stateseq_norep' — Reply to this email directly or view it on GitHub.

alexbw commented 10 years ago

One step further. Should _stateseq and _stateseq_norep be set to None ahead of time?

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)<string> in <module>()
/home/abw11/Code/pyhsmm_library_models/pyhsmm/parallel.py in _call(f, data_id, **kwargs)
     86     @engine_global_namespace
     87     def _call(f,data_id,**kwargs):
---> 88         return f(my_data[data_id],**kwargs)
     89
     90     if engine_globals is not None:
/home/abw11/Code/pyhsmm_library_models/library_subhmm_models.py in _state_sampler(frozen_aBl, **kwargs)
    117                 data=frozen_aBl, # dummy
    118                 frozen_aBl=frozen_aBl,
--> 119                 initialize_from_prior=False,temp=temp,**kwargs)
    120         like = global_model.states_list[-1].log_likelihood()
    121         big_stateseq = global_model.states_list.pop().big_stateseq
/home/abw11/Code/pyhsmm_library_models/pyhsmm/models.pyc in add_data(self, data, stateseq, trunc, right_censoring, left_censoring, **kwargs)
    457             left_censoring=left_censoring,
    458             trunc=trunc,
--> 459             **kwargs))
    460
    461     ### generation
/home/abw11/Code/pyhsmm_library_models/library_subhmm_models.pyc in __init__(self, model, data, frozen_aBl, **kwargs)
     37             self._frozen_aBls = [frozen_aBl] * self.hsmm_trans_matrix.shape[0]
     38         super(HSMMIntNegBinVariantFrozenSubHMMsStates,self).__init__(
---> 39                 model=model,data=data,**kwargs)
     40
     41     # TODO compute likelihoods lazily? push this into aBls? why'd I break it
/home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in __init__(self, model, *args, **kwargs)
   1119     def __init__(self,model,*args,**kwargs):
   1120         self.model = model
-> 1121         super(HSMMIntNegBinVariantSubHMMsStates,self).__init__(model,*args,**kwargs)
   1122         self.data = self.data.astype('float32',copy=False) if self.data is not None else None
   1123         self._alphan = None
/home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in __init__(self, *args, **kwargs)
    735
    736     def __init__(self,*args,**kwargs):
--> 737         HSMMStatesPython.__init__(self,*args,**kwargs)
    738
    739     def clear_caches(self):
/home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in __init__(self, model, right_censoring, left_censoring, trunc, stateseq, **kwargs)
    449         self.trunc = trunc
    450
--> 451         super(HSMMStatesPython,self).__init__(model,stateseq=stateseq,**kwargs)
    452
    453     def _get_stateseq(self):
/home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in __init__(self, model, T, data, stateseq, initialize_from_prior, **kwargs)
     31         else:
     32             if data is not None and not initialize_from_prior:
---> 33                 self.resample(**kwargs)
     34             else:
     35                 self.generate_states()
/home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in resample(self, temp)
   1343     def resample(self,temp=None):
   1344         # TODO something with temperature
-> 1345         self._remove_substates_from_subHMMs()
   1346         alphan = self.messages_forwards_normalized()
   1347         self.sample_backwards_normalized(alphan)
/home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in _remove_substates_from_subHMMs(self)
   1355
   1356     def _remove_substates_from_subHMMs(self):
-> 1357         for superstate, states_obj in zip(self.stateseq_norep, self.substates_list):
   1358             self.model.HMMs[superstate].states_list.remove(states_obj)
   1359         self.substates_list = []
/home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in stateseq_norep(self)
    464     def stateseq_norep(self):
    465         if not hasattr(self,"_stateseq_norep") or self._stateseq_norep is None:
--> 466             self._stateseq_norep, self._durations_censored = rle(self.stateseq)
    467         return self._stateseq_norep
    468
/home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in _get_stateseq(self)
    452
    453     def _get_stateseq(self):
--> 454         return self._stateseq
    455
    456     def _set_stateseq(self,stateseq):
AttributeError: 'HSMMIntNegBinVariantFrozenSubHMMsStates' object has no attribute '_stateseq'
mattjj commented 10 years ago

Yes. That logic was all working at some point; not sure what happened to it.

Matt

Sent from my phone

On Nov 6, 2013, at 12:08 PM, Alex Wiltschko notifications@github.com wrote:

One step further. Should _stateseq and _stateseq_norep be set to None ahead of time?


AttributeError Traceback (most recent call last) in () /home/abw11/Code/pyhsmm_library_models/pyhsmm/parallel.py in _call(f, data_id, kwargs) 86 @engine_global_namespace 87 def _call(f,data_id,kwargs): ---> 88 return f(my_data[data_id],kwargs) 89 90 if engine_globals is not None: /home/abw11/Code/pyhsmm_library_models/library_subhmm_models.py in _state_sampler(frozen_aBl, kwargs) 117 data=frozen_aBl, # dummy 118 frozen_aBl=frozen_aBl, --> 119 initialize_from_prior=False,temp=temp,kwargs) 120 like = global_model.states_list[-1].log_likelihood() 121 big_stateseq = global_model.states_list.pop().big_stateseq /home/abw11/Code/pyhsmm_library_models/pyhsmm/models.pyc in add_data(self, data, stateseq, trunc, right_censoring, left_censoring, _kwargs) 457 left_censoring=left_censoring, 458 trunc=trunc, --> 459 _kwargs)) 460 461 ### generation /home/abw11/Code/pyhsmm_library_models/library_subhmm_models.pyc in init(self, model, data, frozen_aBl, kwargs) 37 self._frozen_aBls = [frozen_aBl] * self.hsmm_trans_matrix.shape[0] 38 super(HSMMIntNegBinVariantFrozenSubHMMsStates,self).init( ---> 39 model=model,data=data,kwargs) 40 41 # TODO compute likelihoods lazily? push this into aBls? why'd I break it /home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in init(self, model, _args, *_kwargs) 1119 def init(self,model,_args,kwargs): 1120 self.model = model -> 1121 super(HSMMIntNegBinVariantSubHMMsStates,self).init(model,_args,**kwargs) 1122 self.data = self.data.astype('float32',copy=False) if self.data is not None else None 1123 self._alphan = None /home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in init__(self, _args, *_kwargs) 735 736 def init(self,*args,kwargs): --> 737 HSMMStatesPython.init(self,_args,__kwargs) 738 739 def clear_caches(self): /home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in init*(self, model, right_censoring, left_censoring, trunc, stateseq, _kwargs) 449 self.trunc = trunc 450 --> 451 super(HSMMStatesPython,self).init(model,stateseq=stateseq,kwargs) 452 453 def _get_stateseq(self): /home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in init(self, model, T, data, stateseq, initialize_from_prior, kwargs) 31 else: 32 if data is not None and not initialize_from_prior: ---> 33 self.resample(kwargs) 34 else: 35 self.generate_states() /home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in resample(self, temp) 1343 def resample(self,temp=None): 1344 # TODO something with temperature -> 1345 self._remove_substates_from_subHMMs() 1346 alphan = self.messages_forwards_normalized() 1347 self.sample_backwards_normalized(alphan) /home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in _remove_substates_from_subHMMs(self) 1355 1356 def _remove_substates_from_subHMMs(self): -> 1357 for superstate, states_obj in zip(self.stateseq_norep, self.substates_list): 1358 self.model.HMMs[superstate].states_list.remove(states_obj) 1359 self.substates_list = [] /home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in stateseq_norep(self) 464 def stateseq_norep(self): 465 if not hasattr(self,"_stateseq_norep") or self._stateseq_norep is None: --> 466 self._stateseq_norep, self._durations_censored = rle(self.stateseq) 467 return self._stateseq_norep 468 /home/abw11/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in _get_stateseq(self) 452 453 def _get_stateseq(self): --> 454 return self._stateseq 455 456 def _set_stateseq(self,stateseq): AttributeError: 'HSMMIntNegBinVariantFrozenSubHMMsStates' object has no attribute '_stateseq' — Reply to this email directly or view it on GitHub.

mattjj commented 10 years ago

This should have been a separate issue! I am going to open a separate issue so I can have the satisfaction of closing two issues.

This issue should be closed. I'm still using 32 bit indices, and it might be a good idea to typedef those to a 64-bit type, but since I never instantiate the fatty transition matrix anymore or linear index into it, these segfaults are fixed.