slinderman / recurrent-slds

Recurrent Switching Linear Dynamical Systems
MIT License
94 stars 23 forks source link

nascar.py fails #4

Closed eliotmoss closed 6 years ago

eliotmoss commented 6 years ago

After what appears to be a successful install, python3 nascar.py produces this: True W_markov: [[ 0. 0. 0. 0.] [ 0. 0. 0. 0.] [ 0. 0. 0. 0.]] True W_input: [[ 100. 0.] [-100. 0.] [ 0. 100.]] Fitting PCA Fitting Sticky ARHMM ......................... [ 25/1000, 0.01sec avg, ETA 13.09 ] ......................... [ 50/1000, 0.01sec avg, ETA 12.89 ] ......................... [ 75/1000, 0.01sec avg, ETA 12.51 ] ......................... [ 100/1000, 0.01sec avg, ETA 12.10 ] ......................... [ 125/1000, 0.01sec avg, ETA 11.80 ] ......................... [ 150/1000, 0.01sec avg, ETA 11.46 ] ......................... [ 175/1000, 0.01sec avg, ETA 11.13 ] ......................... [ 200/1000, 0.01sec avg, ETA 10.83 ] ......................... [ 225/1000, 0.01sec avg, ETA 10.51 ] ......................... [ 250/1000, 0.01sec avg, ETA 10.19 ] ......................... [ 275/1000, 0.01sec avg, ETA 9.86 ] ......................... [ 300/1000, 0.01sec avg, ETA 9.61 ] ......................... [ 325/1000, 0.01sec avg, ETA 9.36 ] ......................... [ 350/1000, 0.01sec avg, ETA 9.13 ] ......................... [ 375/1000, 0.01sec avg, ETA 8.80 ] ......................... [ 400/1000, 0.01sec avg, ETA 8.51 ] ......................... [ 425/1000, 0.01sec avg, ETA 8.12 ] ......................... [ 450/1000, 0.01sec avg, ETA 7.74 ] ......................... [ 475/1000, 0.01sec avg, ETA 7.38 ] ......................... [ 500/1000, 0.01sec avg, ETA 7.01 ] ......................... [ 525/1000, 0.01sec avg, ETA 6.64 ] ......................... [ 550/1000, 0.01sec avg, ETA 6.30 ] ......................... [ 575/1000, 0.01sec avg, ETA 5.93 ] ......................... [ 600/1000, 0.01sec avg, ETA 5.59 ] ......................... [ 625/1000, 0.01sec avg, ETA 5.24 ] ......................... [ 650/1000, 0.01sec avg, ETA 4.88 ] ......................... [ 675/1000, 0.01sec avg, ETA 4.53 ] ......................... [ 700/1000, 0.01sec avg, ETA 4.18 ] ......................... [ 725/1000, 0.01sec avg, ETA 3.82 ] ......................... [ 750/1000, 0.01sec avg, ETA 3.47 ] ......................... [ 775/1000, 0.01sec avg, ETA 3.12 ] ......................... [ 800/1000, 0.01sec avg, ETA 2.77 ] ......................... [ 825/1000, 0.01sec avg, ETA 2.42 ] ......................... [ 850/1000, 0.01sec avg, ETA 2.08 ] ......................... [ 875/1000, 0.01sec avg, ETA 1.73 ] ......................... [ 900/1000, 0.01sec avg, ETA 1.38 ] ......................... [ 925/1000, 0.01sec avg, ETA 1.04 ] ......................... [ 950/1000, 0.01sec avg, ETA 0.69 ] ......................... [ 975/1000, 0.01sec avg, ETA 0.34 ] ......................... [ 1000/1000, 0.01sec avg, ETA 0.00 ]

0.01sec avg, 13.77 total

Fitting Decision List Level 0 Best k: 1 Level 1 Best k: 3 Level 2 Best k: 0 Fitting standard SLDS Initializing dynamics with Gibbs sampling ......................... [ 25/100, 0.01sec avg, ETA 0.57 ] ......................... [ 50/100, 0.01sec avg, ETA 0.39 ] ......................... [ 75/100, 0.01sec avg, ETA 0.19 ] ......................... [ 100/100, 0.01sec avg, ETA 0.00 ]

0.01sec avg, 0.78 total

Traceback (most recent call last): File "nascar.py", line 915, in fit_slds(inputs, z_perm, x_init, y, mask, C_init, N_iters=N_samples) File "nascar.py", line 679, in fit_slds slds.resample_model() File "/usr/lib/python3.6/site-packages/pyhsmm/models.py", line 442, in resample_model self.resample_states(num_procs=num_procs) File "/usr/lib/python3.6/site-packages/pyhsmm/models.py", line 467, in resample_states s.resample() File "/usr/lib/python3.6/site-packages/pyslds/states.py", line 448, in resample self.resample_gaussian_states() File "/usr/lib/python3.6/site-packages/pyslds/states.py", line 459, in resample_gaussian_states info_sample(self.info_params) File "/usr/lib/python3.6/site-packages/pylds/lds_messages_interface.py", line 65, in wrapped return func(check(*args,**kwargs)) File "/usr/lib/python3.6/site-packages/pylds/lds_messages_interface.py", line 95, in _info_argcheck [J_pair_11, J_pair_21, J_pair_22, J_node]) File "/usr/lib/python3.6/site-packages/pylds/lds_messages_interface.py", line 24, in _ensure_ndim assert X.shape[0] == T AssertionError

slinderman commented 6 years ago

Should be fixed in latest refactor.

davidgwyrick commented 6 years ago

I'm still getting the same AssertionError as well and I just installed all of the code and dependencies from source today. Looking at mattjj/pylds repository, the same issue was raised but not addressed.

I got around the error by doing a 'try and except' to catch the AssertionError, but it makes the command-line blow up with errors the whole time the code is running. It finished though.

Any ideas as to why this AssertionError keeps popping up?

slinderman commented 6 years ago

Hi @DgwFreeman,

Thanks for the reminder. I'm afraid I may have forgotten to merge an open pull request in pylds, and I think (though I'm not certain) that this will fix it. Could you try pulling the latest from master and rerunning? I am able to run the nascar demo with the master branch of pylds and pyslds.

Thanks, Scott

davidgwyrick commented 6 years ago

Hi Scott,

That fixed it! Thanks for getting back to me so quickly. I'm trying to use your tool to analyze some odor localization mouse behavior! Thank you for the open-source code.

Best, David

slinderman commented 6 years ago

Awesome, glad it worked! You might find that the rSLDS is a bit overkill for starters. If you run into trouble, I'd recommend backtracking and trying out some simple HMMs (with pyhsmm) or LDS (pylds) and then building up from there. Good luck!

On Thu, Apr 12, 2018 at 2:39 AM, David Wyrick notifications@github.com wrote:

Hi Scott,

That fixed it! Thanks for getting back to me so quickly. I'm trying to use your tool to analyze some odor localization mouse behavior! Thank you for the open-source code.

Best, David

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/slinderman/recurrent-slds/issues/4#issuecomment-380656481, or mute the thread https://github.com/notifications/unsubscribe-auth/AFXwKED34rNoyaZNXSEheO-kDdTfQUSQks5tnr5KgaJpZM4Pv0oc .