new Cython likelihoods in HDDM (problems with compiling Cython extensions)

602 views
Skip to first unread message

Sebastian Bitzer

unread,
Mar 10, 2017, 1:25:50 PM3/10/17
to hddm-users
Dear all, 

perhaps you could comment on what is needed to correctly compile the Cython extensions of HDDM? Background is the following:

I've looked today into adding a single boundary DDM into HDDM, but have stumbled upon some issue with the Cython extensions. The reason I'm trying to do this in Cython instead of simply using an inverse Gaussian likelihood is that I want to also consider across-trial parameter variance as in Ratcliff's DDM and thought that I just reuse the existing code for numeric integration. 

My problem now is that I get strange/bad results when compiling the Cython extensions myself. "python setup.py develop" will produce the shared libraries just fine:

cdfdif_wrapper.cpython-35m-x86_64-linux-gnu.so
wfpt.cpython-35m-x86_64-linux-gnu.so

(using Python 3.5 under Linux), but the example in hddm_demo.ipynb gives first unexpected warnings (see below) and sampling then stops with an AssertionError, or does not converge as expected; with posterior stds around 1 instead of 0.06 and after only 500 s. When I replace the compiled shared libraries with those pre-compiled on conda-forge, sampling seems to work and I get the expected results, but the warnings remain. 

Do you have any idea what could be going on?


Thanks for your help!

Sebastian


Some more info about the setup:
-------------------------------

64-bit Linux Mint 17.3
installed linux packages: 
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
gfortran (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
liblapack-dev 3.5.0-2ubuntu1
libblas-dev 1.2.20110419-7
(not python-scipy as this should come from conda, right?)

conda env with: python=3.5 seaborn pandas spyder jupyter pymc cython patsy
kabuki as git submodule in hddm installed with 'python setup.py develop'

print(hddm.__version__)
print(kabuki.__version__)
print(pm.__version__)
0.6.1
0.6.2
2.3.6


Warning after the call of 'm = hddm.HDDM(data)', 'm.find_starting_values()':
----------------------------------------------------------------------------

/home/bitzer/programs/anaconda/envs/hddm-dev/lib/python3.5/site-packages/scipy/optimize/optimize.py:1876: RuntimeWarning: invalid value encountered in double_scalars
  tmp2 = (x - v) * (fx - fw)
/home/bitzer/programs/anaconda/envs/hddm-dev/lib/python3.5/site-packages/scipy/optimize/optimize.py:1877: RuntimeWarning: invalid value encountered in double_scalars
  p = (x - v) * tmp2 - (x - w) * tmp1
/home/bitzer/programs/anaconda/envs/hddm-dev/lib/python3.5/site-packages/pymc/Node.py:403: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  self.__name__ = input['__name__']


AssertionError encountered with compiled Cython extensions:
-----------------------------------------------------------

AssertionError                            Traceback (most recent call last)
<ipython-input-4-024ebc1556d4> in <module>()
      5 m.find_starting_values()
      6 # start drawing 7000 samples and discarding 5000 as burn-in
----> 7 m.sample(2000, burn=20)

/home/bitzer/ZIH/gitrepos/hddm/kabuki/kabuki/hierarchical.py in sample(self, *args, **kwargs)
    649 
    650         # sample
--> 651         self.mc.sample(*args, **kwargs)
    652 
    653         self.sampled = True

/home/bitzer/programs/anaconda/envs/hddm-dev/lib/python3.5/site-packages/pymc/MCMC.py in sample(self, iter, burn, thin, tune_interval, tune_throughout, save_interval, burn_till_tuned, stop_tuning_after, verbose, progress_bar)
    277 
    278         # Run sampler
--> 279         Sampler.sample(self, iter, length, verbose)
    280 
    281     def _loop(self):

/home/bitzer/programs/anaconda/envs/hddm-dev/lib/python3.5/site-packages/pymc/Model.py in sample(self, iter, length, verbose)
    249         # Loop
    250         self._current_iter = 0
--> 251         self._loop()
    252         self._finalize()
    253 

/home/bitzer/programs/anaconda/envs/hddm-dev/lib/python3.5/site-packages/pymc/MCMC.py in _loop(self)
    313                         print_('Step method %s stepping' % step_method._id)
    314                     # Step the step method
--> 315                     step_method.step()
    316 
    317                 # Record sample to trace, if appropriate

/home/bitzer/ZIH/gitrepos/hddm/kabuki/kabuki/step_methods.py in step(self)
    395                 iter += 1
    396 
--> 397         assert iter < self.maxiter, "Step-out procedure failed"
    398         self.neval += iter
    399         if self.verbose>2:

AssertionError: Step-out procedure failed

Thomas Wiecki

unread,
Mar 11, 2017, 3:56:49 AM3/11/17
to hddm-...@googlegroups.com
Hi Sebastian,

It's hard to say. It sounds like this PR https://github.com/hddm-devs/hddm/pull/38/files could have messed things up, if you don't have RTs > 998 it's hard to see how that could be the case, however.

Has someone else tried the new likelihoods (HDDM 6.1) and found it to work / not work?

Best,
Thomas

--
You received this message because you are subscribed to the Google Groups "hddm-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hddm-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sebastian Bitzer

unread,
Mar 13, 2017, 11:07:31 AM3/13/17
to hddm-users
Hi Thomas,

I don't think that this PR is the reason for the issues I see, because I still have them, when I revert back to commit 14a68eb (update demo to python 3) from 4 Dec 2015.

I have also replicated the strange results that I get in hddm_demo.ipynb on a different computer which has a similar setup, though (Linux Mint 17.3, conda).


Best,

Sebastian
To unsubscribe from this group and stop receiving emails from it, send an email to hddm-users+...@googlegroups.com.

Thomas Wiecki

unread,
Mar 14, 2017, 5:04:21 AM3/14/17
to hddm-...@googlegroups.com
OK, thanks. Must be a different problem then.

To unsubscribe from this group and stop receiving emails from it, send an email to hddm-users+unsubscribe@googlegroups.com.

Mike

unread,
May 4, 2017, 12:48:21 PM5/4/17
to hddm-users
Hi Thomas,

I'm getting the same error that Sebastian lists when running the demo after installing HDDM 6.1. It was working with 6.0, which I had installed via conda. I upgraded using pip install -U hddm, seemingly succesfully: print (hddm.__ version__) returns 0.6.1.

I'm running it in Juptyer notebook on Windows 10, though the same thing happened on a Windows 7 machine.

Best,
Mike
To unsubscribe from this group and stop receiving emails from it, send an email to hddm-users+...@googlegroups.com.

Thomas Wiecki

unread,
May 4, 2017, 5:47:13 PM5/4/17
to hddm-...@googlegroups.com
Which demo are you referring to?

To unsubscribe from this group and stop receiving emails from it, send an email to hddm-users+unsubscribe@googlegroups.com.

Mike

unread,
May 5, 2017, 8:23:53 AM5/5/17
to hddm-users
Sorry - I was running hddm_demo.ipynb (see error below). Executing simple_model.py gives the same error. The error stops them from sampling.

The later section of code in hddm_demo.ipynb for estimating separate drifts rates runs the sampling, but gives an error when it finishes (see error 2 below)

pymc version is 2.3.6
kabuki version is 0.6.2



hddm_demo.ipynb error 1

---------------------------------------------------------------------------

AssertionError                            Traceback (most recent call last)

<ipython-input-7-024ebc1556d4> in <module>()

      5 m.find_starting_values()

      6 # start drawing 7000 samples and discarding 5000 as burn-in

----> 7 m.sample(2000, burn=20)

 

C:\Users\Mike\Anaconda3\lib\site-packages\kabuki\hierarchical.py in sample(self, *args, **kwargs)

    649

    650         # sample

--> 651         self.mc.sample(*args, **kwargs)

    652

    653         self.sampled = True

 

C:\Users\Mike\Anaconda3\lib\site-packages\pymc\MCMC.py in sample(self, iter, burn, thin, tune_interval, tune_throughout, save_interval, burn_till_tuned, stop_tuning_after, verbose, progress_bar)

    277

    278         # Run sampler

--> 279         Sampler.sample(self, iter, length, verbose)

    280

    281     def _loop(self):

 

C:\Users\Mike\Anaconda3\lib\site-packages\pymc\Model.py in sample(self, iter, length, verbose)

    249         # Loop

    250         self._current_iter = 0

--> 251         self._loop()

    252         self._finalize()

    253

 

C:\Users\Mike\Anaconda3\lib\site-packages\pymc\MCMC.py in _loop(self)

    313                         print_('Step method %s stepping' % step_method._id)

    314                     # Step the step method

--> 315                     step_method.step()

    316

    317                 # Record sample to trace, if appropriate

 

C:\Users\Mike\Anaconda3\lib\site-packages\kabuki\step_methods.py in step(self)

    395                 iter += 1

    396

--> 397         assert iter < self.maxiter, "Step-out procedure failed"

    398         self.neval += iter

    399         if self.verbose>2:

 

AssertionError: Step-out procedure failed



------------------------------------------------------
hddm_demo.ipynb error 2

[-----------------100%-----------------] 10001 of 10000 complete in 5404.8 secCould not generate output statistics for t

Could not generate output statistics for t_subj.5

Could not generate output statistics for v_subj(WW).7

(errors are given for all participants/parameters)

 

---------------------------------------------------------------------------

TypeError                                 Traceback (most recent call last)

<ipython-input-9-191835b0b46f> in <module>()

      1 m_stim = hddm.HDDM(data, depends_on={'v': 'stim'})

      2 m_stim.find_starting_values()

----> 3 m_stim.sample(10000, burn=1000)

 

C:\Users\Mike\Anaconda3\lib\site-packages\kabuki\hierarchical.py in sample(self, *args, **kwargs)

    653         self.sampled = True

    654

--> 655         self.gen_stats()

    656         return self.mc

    657

 

C:\Users\Mike\Anaconda3\lib\site-packages\kabuki\hierarchical.py in gen_stats(self, fname, print_hidden, **kwargs)

    730             print_hidden <bool>  - print statistics of hidden nodes

    731         """

--> 732         self.append_stats_to_nodes_db()

    733

    734         sliced_db = self.nodes_db.copy()

 

C:\Users\Mike\Anaconda3\lib\site-packages\kabuki\hierarchical.py in append_stats_to_nodes_db(self, *args, **kwargs)

    782             if self.nodes_db.loc[name, 'hidden']:

    783                 continue

--> 784             self.nodes_db.loc[name, 'mean']   = i_stats['mean']

    785             self.nodes_db.loc[name, 'std']    = i_stats['standard deviation']

    786             self.nodes_db.loc[name, '2.5q']   = i_stats['quantiles'][2.5]

 

TypeError: 'NoneType' object

Thomas Wiecki

unread,
May 5, 2017, 7:34:19 PM5/5/17
to hddm-...@googlegroups.com
This is very odd. I can reproduce the problem but so far no idea why it's failing all of a sudden.

Thomas Wiecki

unread,
May 6, 2017, 4:51:47 PM5/6/17
to hddm-...@googlegroups.com
Can you try setting p_outlier=.05? I.e. m = hddm.HDDM(data, p_outlier=.05) and report if that fixes the sampling issue?
Message has been deleted

Mike

unread,
May 8, 2017, 7:01:18 AM5/8/17
to hddm-users
The sampling runs, but it then gives the output error that I got when using depends_on


[-----------------100%-----------------] 2001 of 2000 complete in 209.9 secCould not generate output statistics for v_subj.12

Could not generate output statistics for a_subj.11

Could not generate output statistics for v_subj.8

Could not generate output statistics for v_subj.1

Could not generate output statistics for a_std

Could not generate output statistics for v_subj.13

Could not generate output statistics for a_subj.13

Could not generate output statistics for v_subj.0

Could not generate output statistics for t_std

Could not generate output statistics for a_subj.6

Could not generate output statistics for v

Could not generate output statistics for a_subj.0

Could not generate output statistics for a

Could not generate output statistics for v_subj.7

Could not generate output statistics for t_subj.11

Could not generate output statistics for a_subj.1

Could not generate output statistics for a_subj.2

Could not generate output statistics for a_subj.12

Could not generate output statistics for t_subj.1

Could not generate output statistics for a_subj.3

Could not generate output statistics for t_subj.8

Could not generate output statistics for a_subj.4

Could not generate output statistics for v_subj.4

Could not generate output statistics for a_subj.8

Could not generate output statistics for v_subj.6

Could not generate output statistics for t_subj.10

Could not generate output statistics for t_subj.0

Could not generate output statistics for a_subj.5

Could not generate output statistics for t_subj.4

Could not generate output statistics for t_subj.12

Could not generate output statistics for a_subj.9

Could not generate output statistics for t_subj.13

Could not generate output statistics for t_subj.5

Could not generate output statistics for t

Could not generate output statistics for a_subj.10

Could not generate output statistics for v_subj.5

Could not generate output statistics for v_subj.9

Could not generate output statistics for t_subj.6

Could not generate output statistics for v_std

Could not generate output statistics for v_subj.3

Could not generate output statistics for v_subj.2

Could not generate output statistics for v_subj.10

Could not generate output statistics for t_subj.9

Could not generate output statistics for v_subj.11

Could not generate output statistics for a_subj.7

Could not generate output statistics for t_subj.2

Could not generate output statistics for t_subj.7

Could not generate output statistics for t_subj.3

---------------------------------------------------------------------------

TypeError                                 Traceback (most recent call last)

<ipython-input-7-ec7a26b34f7f> in <module>()

      6 m.find_starting_values()

      7 # start drawing 7000 samples and discarding 5000 as burn-in

----> 8 m.sample(2000, burn=20)

 

C:\Users\Mike\Anaconda3\lib\site-packages\kabuki\hierarchical.py in sample(self, *args, **kwargs)

    653         self.sampled = True

    654

--> 655         self.gen_stats()

    656         return self.mc

    657

 

C:\Users\Mike\Anaconda3\lib\site-packages\kabuki\hierarchical.py in gen_stats(self, fname, print_hidden, **kwargs)

    730             print_hidden <bool>  - print statistics of hidden nodes

    731         """

--> 732         self.append_stats_to_nodes_db()

    733

    734         sliced_db = self.nodes_db.copy()

 

C:\Users\Mike\Anaconda3\lib\site-packages\kabuki\hierarchical.py in append_stats_to_nodes_db(self, *args, **kwargs)

    782             if self.nodes_db.loc[name, 'hidden']:

    783                 continue

--> 784             self.nodes_db.loc[name, 'mean']   = i_stats['mean']

    785             self.nodes_db.loc[name, 'std']    = i_stats['standard deviation']

    786             self.nodes_db.loc[name, '2.5q']   = i_stats['quantiles'][2.5]

 

TypeError: 'NoneType' object is not subscriptable

Mike

unread,
May 19, 2017, 12:49:07 PM5/19/17
to hddm-users
Hi Thomas,

In case it helps diagnose the issue, I tried installing version 0.6.0 using conda, and then simply copying and pasting all the 0.6.1 files/folders over the ones in  the site packages>hddm folder. Things run without errors now, including for data with missing RTs on the surface of it (I'll need to check parameter recovery for it still).

Perhaps something else happened with the installation of .0.6.1 via pip.



On Saturday, 6 May 2017 21:51:47 UTC+1, Thomas wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to hddm-users+...@googlegroups.com.

Thomas Wiecki

unread,
May 22, 2017, 8:31:46 AM5/22/17
to hddm-...@googlegroups.com
Which numpy version do you use?

To unsubscribe from this group and stop receiving emails from it, send an email to hddm-users+unsubscribe@googlegroups.com.

Mike

unread,
May 22, 2017, 1:09:26 PM5/22/17
to hddm-users

On a machine that it was working - 1.11.3
On one where it wasn't (hddm version 0.6.1 installed via pip) - 1.12.1

Rolling back to 1.11.3 on the machine that didn't work seems to fix it.

Thomas Wiecki

unread,
May 22, 2017, 3:11:18 PM5/22/17
to hddm-...@googlegroups.com
OK, perfect. Thanks for checking.

To unsubscribe from this group and stop receiving emails from it, send an email to hddm-users+unsubscribe@googlegroups.com.

Thomas Wiecki

unread,
Jun 24, 2017, 2:34:52 PM6/24/17
to hddm-...@googlegroups.com
OK, I submitted a patch, not quite sure if it really works but please test it by install hddm master. This is the fix: https://github.com/hddm-devs/hddm/commit/f3855472c1864a567b4448ee58c580b3efee199c

Thomas Wiecki

unread,
Jun 24, 2017, 2:36:11 PM6/24/17
to hddm-...@googlegroups.com
pip install -U --no-deps git+https://github.com/hddm-devs/hddm

Luisa Horsten

unread,
Jan 18, 2018, 3:49:05 PM1/18/18
to hddm-users
Hi folks,

I am facing the same error:
"RuntimeWarning: invalid value encountered in double_scalars
  tmp2 = (x - v) * (fx - fw)"

I'm not sure if I understood all of this conversation correctly, but running "pip install -U --no-deps git+https://github.com/hddm-devs/hddm" did not help in my case.

As I'm a total beginner with hddm, and don't have much experience with python, I have absolutely no clue what could possibly be wrong, so I'll appreciate any hints!


Thomas Wiecki

unread,
Jan 22, 2018, 3:56:57 PM1/22/18
to hddm-...@googlegroups.com
Hi Luisa,

Can't you install via conda?

Best,
Thomas

To unsubscribe from this group and stop receiving emails from it, send an email to hddm-users+unsubscribe@googlegroups.com.

Luisa Horsten

unread,
Jan 24, 2018, 10:29:02 AM1/24/18
to hddm-users
Hi Thomas,

if I try to install via conda I get the following error:

UnsatisfiableError: The following specifications were found to be in conflict:
  - hddm -> kabuki -> python 3.3* -> xz 5.0.5
  - python 3.6*

I'm assuming that means I would have to downgrade python to 3.3. But if I run

conda install python=3.3

I get the error

UnsatisfiableError: The following specifications were found to be in conflict:
  - python 3.3*
  - typing -> python 2.7*

And then I'm basically stuck.

Thomas Wiecki

unread,
Jan 24, 2018, 11:02:53 AM1/24/18
to hddm-...@googlegroups.com
Hi Luisa,

Can you try with python 2.7?

To unsubscribe from this group and stop receiving emails from it, send an email to hddm-users+unsubscribe@googlegroups.com.

Luisa Horsten

unread,
Jan 25, 2018, 9:52:06 AM1/25/18
to hddm-users
Hi Thomas,

sure. Still gives the same error, though, plus additional one:
ShimWarning: The `IPython.parallel` package has been deprecated since IPython 4.0. You should import from ipyparallel instead.
  "You should import from ipyparallel instead.", ShimWarning)


Luisa Horsten

unread,
Jan 31, 2018, 11:21:43 AM1/31/18
to hddm-users
I just tried to get hddm running on a windows machine and encounter the same exact errors

model.find_starting_values()
RuntimeWarning: invalid value encountered in double_scalars
  tmp2 = (x - v) * (fx - fw)

model.sample(2000, burn=20)
VisibleDeprecationWarning: u
sing a non-integer number instead of an integer will result in an error in the future
  self.__name__ = input['__name__']



Sam Mathias

unread,
Jan 31, 2018, 11:33:38 AM1/31/18
to hddm-users
Hi Luisa, those are warnings rather than errors. Do you actually get errors, such that your code doesn't sample the model?

--
Samuel R. Mathias, Ph.D.
Associate Research Scientist (ARS)
Neurocognition, Neurocomputation and Neurogenetics (n3) Division
Yale University School of Medicine
40 Temple Street, Room 694
New Haven CT 06511
http://www.srmathias.com

To unsubscribe from this group and stop receiving emails from it, send an email to hddm-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages