dattalab / pyhsmm-library-models

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

Can't copy a sample for parallel HSMM #16

Closed alexbw closed 11 years ago

alexbw commented 11 years ago
Computed and saved to cache: d58de7c81ebec6fa5e51ab0bfee7da1c6a5990c6
Computed and saved to cache: 215ba5f4bbfc58d9a9fc3906310f2898e75cfc02
Computed and saved to cache: a2c32900a69e710e3a634d850a3b342ad4cf7e63
Computed and saved to cache: 6475d1f079e3791c95ab111adf9718a595f78d54
Computed and saved to cache: 4d515aa02f9db94b12f277b4f05d0a07ac951dd1
Computed and saved to cache: cdf07e9fec7038582399ff68b98ea44a3a7d5b4f
Computed and saved to cache: 597a79590713ab46f0aa6a6dc122b868ee1df68e
Computed and saved to cache: a31bfd449e275a7f2e1eec5978a5db781db04da3
Computed and saved to cache: 0a6229f74961c08a925777e7a93a7ef1c061d7cb
     This iteration: 0.000071
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/home/alexbw/anaconda/lib/python2.7/site-packages/IPython/utils/py3compat.pyc in execfile(fname, *where)
    202             else:
    203                 filename = fname
--> 204             __builtin__.execfile(filename, *where)

/home/alexbw/Code/pymouse/scripts/build_model.py in <module>()
    296 
    297 
--> 298 baker.run()

/home/alexbw/anaconda/lib/python2.7/site-packages/baker.pyc in run(self, argv, main, help_on_error, outfile, errorfile, helpfile, errorcode, instance)
    821 
    822         try:
--> 823             value = self.apply(*self.parse(argv), instance=instance)
    824             if main and value is not None:
    825                 self.write(outfile, str(value) + '\n')

/home/alexbw/anaconda/lib/python2.7/site-packages/baker.pyc in apply(self, scriptname, cmd, args, kwargs, instance)
    799         if cmd.is_method and instance is not None:
    800             return cmd.fn(instance, *newargs, **newkwargs)
--> 801         return cmd.fn(*newargs, **newkwargs)
    802 
    803     def run(self, argv=None, main=True, help_on_error=False,

/home/alexbw/Code/pymouse/scripts/build_model.py in build(datadir, output_folder, n_iter, n_iter_burnin, n_states, n_examples_r, avg_r, avg_dur, data_sub_idx, alpha_a_0, alpha_b_0, gamma_a_0, gamma_b_0, frozen_a_0, frozen_b_0, r, spinogram_plot_idx, use_parallel)
    184                                     frozen_b_0=frozen_b_0,
    185                                     output_folder=output_folder)
--> 186     lhsmmModel.fit(X=data[data_sub_idx], X_held_out=data_test[data_sub_idx], parallel=use_parallel, left_censoring=True)
    187 
    188 

/home/alexbw/Code/pymouse/lhsmm.pyc in fit(self, X, y, X_held_out, parallel, left_censoring, max_temp)
    324             else:
    325                 self.hsmm_model.resample_model_parallel()
--> 326                 self.samples_.append(self.hsmm_model.copy_sample())
    327             this_likelihood = self.hsmm_model.log_likelihood()
    328             self.sample_likelihoods_.append(this_likelihood)

/home/alexbw/Code/pyhsmm_library_models/pyhsmm/models.pyc in copy_sample(self)
    477 
    478     def copy_sample(self):
--> 479         new = super(HSMM,self).copy_sample()
    480         new.dur_distns = [d.copy_sample() for d in self.dur_distns]
    481         return new

/home/alexbw/Code/pyhsmm_library_models/pyhsmm/models.pyc in copy_sample(self)
    177         new.trans_distn = self.trans_distn.copy_sample()
    178         new.init_state_distn = self.init_state_distn.copy_sample()
--> 179         new.states_list = [s.copy_sample(new) for s in self.states_list]
    180         return new
    181 

/home/alexbw/Code/pyhsmm_library_models/pyhsmm/internals/states.pyc in copy_sample(self, *args, **kwargs)
    670 
    671     def copy_sample(self,*args,**kwargs):
--> 672         return HSMMStatesPython.copy_sample(*args,**kwargs)
    673 
    674     @property

TypeError: unbound method copy_sample() must be called with HSMMStatesPython instance as first argument (got LibraryHSMMIntNegBinVariant instance instead)
alexbw commented 11 years ago

Can be reproduced by

%run /home/alexbw/Code/pymouse/scripts/build_model.py build \
    --datadir="/home/alexbw/Data/C57-1+2-data-8-4-2013-fortesting.npz"\
    --output_folder="/home/alexbw/Data/model_test/"\
    --data_sub_idx=np.r_[0:10000]\
    --n_iter=400\
    --n_iter_burnin=0\
    --n_examples_r=5\
    --avg_r=5\
    --avg_dur=5\
    --alpha_a_0=1.0\
    --alpha_b_0=0.1\
    --gamma_a_0=0.1\
    --gamma_b_0=200.0\
    --frozen_a_0=1.0\
    --frozen_b_0 0.05\
    --r=np.r_[0,0,1,1,1,1,1,1,1,1,1,1,1]\
    --use_parallel=True
mattjj commented 11 years ago

Fixed in b0cb076 of pyhsmm.

mattjj commented 11 years ago

Updated pyhsmm pointer in 4125fd9.