bambinos / bambi

BAyesian Model-Building Interface (Bambi) in Python.
https://bambinos.github.io/bambi/
MIT License
1.06k stars 122 forks source link

Unexpected Error when testing Bambi package #389

Closed sreedat closed 3 years ago

sreedat commented 3 years ago

I'm working on a laptop with Windows 10 and using Anaconda 64-bit. I have created an environment for working with Pymc3 and bambi. I have been able to test Pymc3 and it is working for an Hierarchical Linear Regression model. For bambi I was testing the example described at this link (growth curves of Pigs example) [https://bambinos.github.io/bambi/master/notebooks/multi-level_regression.html]. I run into an error I had not seen with bambi before (actually from the output this looks like it is occurring at Theano, but I'm not a programmer or a developer).

Here is my environment and the complete traceback of the error

# packages in environment at C:\ProgramData\Anaconda3\envs\pm3env:
#
# Name                    Version                   Build  Channel
argon2-cffi               20.1.0           py37hcc03f2d_2    conda-forge
arviz                     0.11.1                   pypi_0    pypi
async_generator           1.10                       py_0    conda-forge
attrs                     21.2.0             pyhd8ed1ab_0    conda-forge
backcall                  0.2.0              pyh9f0ad1d_0    conda-forge
backports                 1.0                        py_2    conda-forge
backports.functools_lru_cache 1.6.4              pyhd8ed1ab_0    conda-forge
bambi                     0.5.0                    pypi_0    pypi
blas                      1.0                         mkl
bleach                    4.0.0              pyhd8ed1ab_0    conda-forge
ca-certificates           2021.5.30            h5b45459_0    conda-forge
cached-property           1.5.2                    pypi_0    pypi
cachetools                4.2.2                    pypi_0    pypi
cairo                     1.16.0            hb19e0ff_1008    conda-forge
certifi                   2021.5.30        py37h03978a9_0    conda-forge
cffi                      1.14.6           py37hd8e9650_0    conda-forge
cftime                    1.5.0                    pypi_0    pypi
colorama                  0.4.4              pyh9f0ad1d_0    conda-forge
cycler                    0.10.0                     py_2    conda-forge
decorator                 5.0.9              pyhd8ed1ab_0    conda-forge
defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
dill                      0.3.4                    pypi_0    pypi
entrypoints               0.3             pyhd8ed1ab_1003    conda-forge
et-xmlfile                1.1.0                    pypi_0    pypi
expat                     2.4.1                h39d44d4_0    conda-forge
fastprogress              1.0.0                    pypi_0    pypi
filelock                  3.0.12                   pypi_0    pypi
font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
font-ttf-ubuntu           0.83                 hab24e00_0    conda-forge
fontconfig                2.13.1            h1989441_1005    conda-forge
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
formulae                  0.1.3                    pypi_0    pypi
freetype                  2.10.4               h546665d_1    conda-forge
fribidi                   1.0.10               h8d14728_0    conda-forge
getopt-win32              0.1                  h8ffe710_0    conda-forge
gettext                   0.19.8.1          h1a89ca6_1005    conda-forge
graphite2                 1.3.13                     1000    conda-forge
graphviz                  2.48.0               hefbd956_0    conda-forge
gts                       0.7.6                h7c369d9_2    conda-forge
h5py                      3.1.0                    pypi_0    pypi
harfbuzz                  2.8.2                hc601d6f_0    conda-forge
icc_rt                    2019.0.0             h0cc432a_1
icu                       68.1                 h0e60522_0    conda-forge
importlib-metadata        2.1.1                    pypi_0    pypi
intel-openmp              2021.3.0          h57928b3_3372    conda-forge
ipykernel                 5.5.5            py37h7813e69_0    conda-forge
ipython                   7.26.0           py37h4038f58_0    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
ipywidgets                7.6.3              pyhd3eb1b0_1
jbig                      2.1               h8d14728_2003    conda-forge
jedi                      0.18.0           py37h03978a9_2    conda-forge
jinja2                    3.0.1              pyhd8ed1ab_0    conda-forge
jpeg                      9d                   h8ffe710_0    conda-forge
jsonschema                3.2.0              pyhd8ed1ab_3    conda-forge
jupyter                   1.0.0                    py37_7
jupyter_client            6.1.12             pyhd8ed1ab_0    conda-forge
jupyter_console           6.4.0              pyhd8ed1ab_0    conda-forge
jupyter_core              4.7.1            py37h03978a9_0    conda-forge
jupyterlab_pygments       0.1.2              pyh9f0ad1d_0    conda-forge
jupyterlab_widgets        1.0.0              pyhd8ed1ab_1    conda-forge
kiwisolver                1.3.1            py37h8c56517_1    conda-forge
lcms2                     2.12                 h2a16943_0    conda-forge
lerc                      2.2.1                h0e60522_0    conda-forge
libclang                  11.1.0          default_h5c34c98_1    conda-forge
libdeflate                1.7                  h8ffe710_5    conda-forge
libffi                    3.3                  h0e60522_2    conda-forge
libgd                     2.3.2                h138e682_0    conda-forge
libglib                   2.68.3               h1e62bf3_0    conda-forge
libiconv                  1.16                 he774522_0    conda-forge
libpng                    1.6.37               h1d00b33_2    conda-forge
libpython                 2.1                      py37_0
libsodium                 1.0.18               h8d14728_1    conda-forge
libtiff                   4.3.0                h0c97f57_1    conda-forge
libwebp                   1.2.0                h57928b3_0    conda-forge
libwebp-base              1.2.0                h8ffe710_2    conda-forge
libxcb                    1.13              hcd874cb_1003    conda-forge
libxml2                   2.9.12               hf5bbc77_0    conda-forge
llvmlite                  0.36.0           py37habb0c8c_0    conda-forge
lz4-c                     1.9.3                h8ffe710_1    conda-forge
m2w64-gcc-libgfortran     5.3.0                         6    conda-forge
m2w64-gcc-libs            5.3.0                         7    conda-forge
m2w64-gcc-libs-core       5.3.0                         7    conda-forge
m2w64-gmp                 6.1.0                         2    conda-forge
m2w64-libwinpthread-git   5.0.0.4634.697f757               2    conda-forge
markupsafe                2.0.1            py37hcc03f2d_0    conda-forge
matplotlib                3.3.2                haa95532_0
matplotlib-base           3.3.2            py37h3379fd5_1    conda-forge
matplotlib-inline         0.1.2              pyhd8ed1ab_2    conda-forge
mistune                   0.8.4           py37hcc03f2d_1004    conda-forge
mkl                       2020.4             hb70f87d_311    conda-forge
mkl-service               2.3.0            py37h196d8e1_0
mkl_fft                   1.3.0            py37hda49f71_1    conda-forge
mkl_random                1.2.0            py37h414f9d2_1    conda-forge
mpmath                    1.2.1              pyhd8ed1ab_0    conda-forge
msys2-conda-epoch         20160418                      1    conda-forge
nbclient                  0.5.3              pyhd8ed1ab_0    conda-forge
nbconvert                 6.1.0            py37h03978a9_0    conda-forge
nbformat                  5.1.3              pyhd8ed1ab_0    conda-forge
nest-asyncio              1.5.1              pyhd8ed1ab_0    conda-forge
netcdf4                   1.5.7                    pypi_0    pypi
notebook                  6.4.0              pyha770c72_0    conda-forge
numba                     0.53.1           py37h4e635f9_0    conda-forge
numpy                     1.19.2           py37hadc3359_0
numpy-base                1.19.2           py37ha3acd2a_0
olefile                   0.46               pyh9f0ad1d_1    conda-forge
openjpeg                  2.4.0                hb211442_1    conda-forge
openpyxl                  3.0.7                    pypi_0    pypi
openssl                   1.1.1k               h8ffe710_0    conda-forge
packaging                 21.0               pyhd8ed1ab_0    conda-forge
pandas                    1.2.1            py37hf11a4ad_0
pandoc                    2.14.1               h8ffe710_0    conda-forge
pandocfilters             1.4.2                      py_1    conda-forge
pango                     1.48.7               hd84fcdd_0    conda-forge
parso                     0.8.2              pyhd8ed1ab_0    conda-forge
patsy                     0.5.1                    pypi_0    pypi
pcre                      8.45                 h0e60522_0    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pillow                    8.3.1            py37hd7d9ad0_0    conda-forge
pip                       20.3.3           py37haa95532_0
pixman                    0.40.0               h8ffe710_0    conda-forge
prometheus_client         0.11.0             pyhd8ed1ab_0    conda-forge
prompt-toolkit            3.0.19             pyha770c72_0    conda-forge
prompt_toolkit            3.0.19               hd8ed1ab_0    conda-forge
pthread-stubs             0.4               hcd874cb_1001    conda-forge
pycparser                 2.20               pyh9f0ad1d_2    conda-forge
pygments                  2.9.0              pyhd8ed1ab_0    conda-forge
pymc3                     3.11.2                   pypi_0    pypi
pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
pyqt                      5.12.3           py37h03978a9_7    conda-forge
pyqt-impl                 5.12.3           py37hf2a7229_7    conda-forge
pyqt5-sip                 4.19.18          py37hf2a7229_7    conda-forge
pyqtchart                 5.12             py37hf2a7229_7    conda-forge
pyqtwebengine             5.12.1           py37hf2a7229_7    conda-forge
pyrsistent                0.17.3           py37hcc03f2d_2    conda-forge
python                    3.7.9                h60c2a47_0
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python-graphviz           0.16               pyh243d235_2    conda-forge
python_abi                3.7                     2_cp37m    conda-forge
pytz                      2021.1             pyhd8ed1ab_0    conda-forge
pywin32                   300              py37hcc03f2d_0    conda-forge
pywinpty                  1.1.3            py37h7f67f24_0    conda-forge
pyzmq                     22.2.0           py37hcce574b_0    conda-forge
qt                        5.12.9               h5909a2a_4    conda-forge
qtconsole                 5.1.1              pyhd8ed1ab_0    conda-forge
qtpy                      1.9.0                      py_0    conda-forge
scipy                     1.7.1                    pypi_0    pypi
semver                    2.13.0                   pypi_0    pypi
send2trash                1.7.1              pyhd8ed1ab_0    conda-forge
setuptools                49.6.0           py37h03978a9_3    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
sqlite                    3.36.0               h8ffe710_0    conda-forge
statsmodels               0.12.2                   pypi_0    pypi
sympy                     1.7.1            py37h03978a9_1    conda-forge
terminado                 0.10.1           py37h03978a9_0    conda-forge
testpath                  0.5.0              pyhd8ed1ab_0    conda-forge
theano-pymc               1.1.2                    pypi_0    pypi
tk                        8.6.10               h8ffe710_1    conda-forge
tornado                   6.1              py37hcc03f2d_1    conda-forge
traitlets                 5.0.5                      py_0    conda-forge
typing                    3.7.4.3                  pypi_0    pypi
typing_extensions         3.10.0.0           pyha770c72_0    conda-forge
ucrt                      10.0.20348.0         h57928b3_0    conda-forge
vc                        14.2                 hb210afc_5    conda-forge
vs2015_runtime            14.29.30037          h902a5da_5    conda-forge
watermark                 2.2.0                    pypi_0    pypi
wcwidth                   0.2.5              pyh9f0ad1d_2    conda-forge
webencodings              0.5.1                      py_1    conda-forge
wheel                     0.36.2             pyhd3deb0d_0    conda-forge
widgetsnbextension        3.5.1            py37h03978a9_4    conda-forge
wincertstore              0.2             py37h03978a9_1006    conda-forge
winpty                    0.4.3                         4    conda-forge
xarray                    0.16.2                   pypi_0    pypi
xorg-kbproto              1.0.7             hcd874cb_1002    conda-forge
xorg-libice               1.0.10               hcd874cb_0    conda-forge
xorg-libsm                1.2.3             hcd874cb_1000    conda-forge
xorg-libx11               1.7.2                hcd874cb_0    conda-forge
xorg-libxau               1.0.9                hcd874cb_0    conda-forge
xorg-libxdmcp             1.1.3                hcd874cb_0    conda-forge
xorg-libxext              1.3.4                hcd874cb_1    conda-forge
xorg-libxpm               3.5.13               hcd874cb_0    conda-forge
xorg-libxt                1.2.1                hcd874cb_2    conda-forge
xorg-xextproto            7.3.0             hcd874cb_1002    conda-forge
xorg-xproto               7.0.31            hcd874cb_1007    conda-forge
xz                        5.2.5                h62dcd97_1    conda-forge
zeromq                    4.3.4                h0e60522_0    conda-forge
zipp                      3.5.0              pyhd8ed1ab_0    conda-forge
zlib                      1.2.11            h62dcd97_1010    conda-forge
zstd                      1.5.0                h6255e5f_0    conda-forge

Model I tried to run is:

model = bmb.Model("Weight ~ Time + (Time|Pig)", data)
results = model.fit()

And the error I get is:

---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-11-99071b9bde96> in <module>
      1 model = bmb.Model("Weight ~ Time + (Time|Pig)", data)
----> 2 results = model.fit()

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\bambi\models.py in fit(self, omit_offsets, backend, **kwargs)
    213             )
    214 
--> 215         return self.backend.run(omit_offsets=omit_offsets, **kwargs)
    216 
    217     def build(self, backend="pymc"):

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\bambi\backends\pymc.py in run(self, start, method, init, n_init, omit_offsets, **kwargs)
    139                     n_init=n_init,
    140                     return_inferencedata=True,
--> 141                     **kwargs,
    142                 )
    143 

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\pymc3\sampling.py in sample(draws, step, init, n_init, start, trace, chain_idx, chains, cores, tune, progressbar, model, random_seed, discard_tuned_samples, compute_convergence_checks, callback, jitter_max_retries, return_inferencedata, idata_kwargs, mp_ctx, pickle_backend, **kwargs)
    502                 progressbar=progressbar,
    503                 jitter_max_retries=jitter_max_retries,
--> 504                 **kwargs,
    505             )
    506             if start is None:

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\pymc3\sampling.py in init_nuts(init, chains, n_init, model, random_seed, progressbar, jitter_max_retries, **kwargs)
   2185         raise ValueError(f"Unknown initializer: {init}.")
   2186 
-> 2187     step = pm.NUTS(potential=potential, model=model, **kwargs)
   2188 
   2189     return start, step

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\pymc3\step_methods\hmc\nuts.py in __init__(self, vars, max_treedepth, early_max_treedepth, **kwargs)
    166         `pm.sample` to the desired number of tuning steps.
    167         """
--> 168         super().__init__(vars, **kwargs)
    169 
    170         self.max_treedepth = max_treedepth

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\pymc3\step_methods\hmc\base_hmc.py in __init__(self, vars, scaling, step_scale, is_cov, model, blocked, potential, dtype, Emax, target_accept, gamma, k, t0, adapt_step_size, step_rand, **theano_kwargs)
     86         vars = inputvars(vars)
     87 
---> 88         super().__init__(vars, blocked=blocked, model=model, dtype=dtype, **theano_kwargs)
     89 
     90         self.adapt_step_size = adapt_step_size

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\pymc3\step_methods\arraystep.py in __init__(self, vars, model, blocked, dtype, logp_dlogp_func, **theano_kwargs)
    252 
    253         if logp_dlogp_func is None:
--> 254             func = model.logp_dlogp_function(vars, dtype=dtype, **theano_kwargs)
    255         else:
    256             func = logp_dlogp_func

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\pymc3\model.py in logp_dlogp_function(self, grad_vars, tempered, **kwargs)
   1002         varnames = [var.name for var in grad_vars]
   1003         extra_vars = [var for var in self.free_RVs if var.name not in varnames]
-> 1004         return ValueGradFunction(costs, grad_vars, extra_vars, **kwargs)
   1005 
   1006     @property

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\pymc3\model.py in __init__(self, costs, grad_vars, extra_vars, dtype, casting, compute_grads, **kwargs)
    689 
    690         if compute_grads:
--> 691             grad = tt.grad(self._cost_joined, self._vars_joined)
    692             grad.name = "__grad"
    693             outputs = [self._cost_joined, grad]

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in grad(cost, wrt, consider_constant, disconnected_inputs, add_names, known_grads, return_disconnected, null_gradients)
    637             assert g.type.dtype in theano.tensor.float_dtypes
    638 
--> 639     rval = _populate_grad_dict(var_to_app_to_idx, grad_dict, wrt, cost_name)
    640 
    641     for i in range(len(rval)):

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in _populate_grad_dict(var_to_app_to_idx, grad_dict, wrt, cost_name)
   1438         return grad_dict[var]
   1439 
-> 1440     rval = [access_grad_cache(elem) for elem in wrt]
   1441 
   1442     return rval

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in <listcomp>(.0)
   1438         return grad_dict[var]
   1439 
-> 1440     rval = [access_grad_cache(elem) for elem in wrt]
   1441 
   1442     return rval

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in access_grad_cache(var)
   1391                     for idx in node_to_idx[node]:
   1392 
-> 1393                         term = access_term_cache(node)[idx]
   1394 
   1395                         if not isinstance(term, Variable):

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in access_term_cache(node)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in <listcomp>(.0)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in access_grad_cache(var)
   1391                     for idx in node_to_idx[node]:
   1392 
-> 1393                         term = access_term_cache(node)[idx]
   1394 
   1395                         if not isinstance(term, Variable):

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in access_term_cache(node)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in <listcomp>(.0)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in access_grad_cache(var)
   1391                     for idx in node_to_idx[node]:
   1392 
-> 1393                         term = access_term_cache(node)[idx]
   1394 
   1395                         if not isinstance(term, Variable):

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in access_term_cache(node)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in <listcomp>(.0)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in access_grad_cache(var)
   1391                     for idx in node_to_idx[node]:
   1392 
-> 1393                         term = access_term_cache(node)[idx]
   1394 
   1395                         if not isinstance(term, Variable):

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in access_term_cache(node)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in <listcomp>(.0)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in access_grad_cache(var)
   1391                     for idx in node_to_idx[node]:
   1392 
-> 1393                         term = access_term_cache(node)[idx]
   1394 
   1395                         if not isinstance(term, Variable):

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in access_term_cache(node)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in <listcomp>(.0)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in access_grad_cache(var)
   1391                     for idx in node_to_idx[node]:
   1392 
-> 1393                         term = access_term_cache(node)[idx]
   1394 
   1395                         if not isinstance(term, Variable):

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in access_term_cache(node)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in <listcomp>(.0)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in access_grad_cache(var)
   1391                     for idx in node_to_idx[node]:
   1392 
-> 1393                         term = access_term_cache(node)[idx]
   1394 
   1395                         if not isinstance(term, Variable):

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in access_term_cache(node)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in <listcomp>(.0)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in access_grad_cache(var)
   1391                     for idx in node_to_idx[node]:
   1392 
-> 1393                         term = access_term_cache(node)[idx]
   1394 
   1395                         if not isinstance(term, Variable):

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in access_term_cache(node)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in <listcomp>(.0)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in access_grad_cache(var)
   1391                     for idx in node_to_idx[node]:
   1392 
-> 1393                         term = access_term_cache(node)[idx]
   1394 
   1395                         if not isinstance(term, Variable):

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in access_term_cache(node)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in <listcomp>(.0)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in access_grad_cache(var)
   1391                     for idx in node_to_idx[node]:
   1392 
-> 1393                         term = access_term_cache(node)[idx]
   1394 
   1395                         if not isinstance(term, Variable):

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in access_term_cache(node)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in <listcomp>(.0)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in access_grad_cache(var)
   1391                     for idx in node_to_idx[node]:
   1392 
-> 1393                         term = access_term_cache(node)[idx]
   1394 
   1395                         if not isinstance(term, Variable):

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\gradient.py in access_term_cache(node)
   1218                             )
   1219 
-> 1220                 input_grads = node.op.L_op(inputs, node.outputs, new_output_grads)
   1221 
   1222                 if input_grads is None:

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\tensor\elemwise.py in L_op(self, inputs, outs, ograds)
    562 
    563         # compute grad with respect to broadcasted input
--> 564         rval = self._bgrad(inputs, outs, ograds)
    565 
    566         # TODO: make sure that zeros are clearly identifiable

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\tensor\elemwise.py in _bgrad(self, inputs, outputs, ograds)
    666                 ret.append(None)
    667                 continue
--> 668             ret.append(transform(scalar_igrad))
    669 
    670         return ret

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\tensor\elemwise.py in transform(r)
    657                 return DimShuffle((), ["x"] * nd)(res)
    658 
--> 659             new_r = Elemwise(node.op, {})(*[transform(ipt) for ipt in node.inputs])
    660             return new_r
    661 

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\tensor\elemwise.py in <listcomp>(.0)
    657                 return DimShuffle((), ["x"] * nd)(res)
    658 
--> 659             new_r = Elemwise(node.op, {})(*[transform(ipt) for ipt in node.inputs])
    660             return new_r
    661 

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\tensor\elemwise.py in transform(r)
    657                 return DimShuffle((), ["x"] * nd)(res)
    658 
--> 659             new_r = Elemwise(node.op, {})(*[transform(ipt) for ipt in node.inputs])
    660             return new_r
    661 

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\graph\op.py in __call__(self, *inputs, **kwargs)
    251 
    252         if config.compute_test_value != "off":
--> 253             compute_test_value(node)
    254 
    255         if self.default_output is not None:

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\graph\op.py in compute_test_value(node)
    124 
    125     # Create a thunk that performs the computation
--> 126     thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=[])
    127     thunk.inputs = [storage_map[v] for v in node.inputs]
    128     thunk.outputs = [storage_map[v] for v in node.outputs]

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\graph\op.py in make_thunk(self, node, storage_map, compute_map, no_recycling, impl)
    632             )
    633             try:
--> 634                 return self.make_c_thunk(node, storage_map, compute_map, no_recycling)
    635             except (NotImplementedError, MethodNotDefined):
    636                 # We requested the c code, so don't catch the error.

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\graph\op.py in make_c_thunk(self, node, storage_map, compute_map, no_recycling)
    599                 raise NotImplementedError("float16")
    600         outputs = cl.make_thunk(
--> 601             input_storage=node_input_storage, output_storage=node_output_storage
    602         )
    603         thunk, node_input_filters, node_output_filters = outputs

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\link\c\basic.py in make_thunk(self, input_storage, output_storage, storage_map)
   1202         init_tasks, tasks = self.get_init_tasks()
   1203         cthunk, module, in_storage, out_storage, error_storage = self.__compile__(
-> 1204             input_storage, output_storage, storage_map
   1205         )
   1206 

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\link\c\basic.py in __compile__(self, input_storage, output_storage, storage_map)
   1140             input_storage,
   1141             output_storage,
-> 1142             storage_map,
   1143         )
   1144         return (

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\link\c\basic.py in cthunk_factory(self, error_storage, in_storage, out_storage, storage_map)
   1632             for node in self.node_order:
   1633                 node.op.prepare_node(node, storage_map, None, "c")
-> 1634             module = get_module_cache().module_from_key(key=key, lnk=self)
   1635 
   1636         vars = self.inputs + self.outputs + self.orphans

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\link\c\cmodule.py in module_from_key(self, key, lnk)
   1189             try:
   1190                 location = dlimport_workdir(self.dirname)
-> 1191                 module = lnk.compile_cmodule(location)
   1192                 name = module.__file__
   1193                 assert name.startswith(location)

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\link\c\basic.py in compile_cmodule(self, location)
   1548                     lib_dirs=self.lib_dirs(),
   1549                     libs=libs,
-> 1550                     preargs=preargs,
   1551                 )
   1552             except Exception as e:

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\link\c\cmodule.py in compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module, hide_symbols)
   2545             compile_stderr = compile_stderr.replace("\n", ". ")
   2546             raise Exception(
-> 2547                 f"Compilation failed (return status={status}): {compile_stderr}"
   2548             )
   2549         elif config.cmodule__compilation_warning and compile_stderr:

Exception: ("Compilation failed (return status=1): C:\\Users\\sreedatta\\AppData\\Local\\Theano\\compiledir_Windows-10-10.0.19041-SP0-Intel64_Family_6_Model_140_Stepping_1_GenuineIntel-3.7.9-64\\tmp81eb_5sq\\mod.cpp: In member function 'int {anonymous}::__struct_compiled_op_m67599e776bb0a5edbe20464e4ef6902fada5652e9f038845aa3f408620203691::run()':. C:\\Users\\sreedatta\\AppData\\Local\\Theano\\compiledir_Windows-10-10.0.19041-SP0-Intel64_Family_6_Model_140_Stepping_1_GenuineIntel-3.7.9-64\\tmp81eb_5sq\\mod.cpp:506:39: warning: narrowing conversion of 'V5_n0' from 'npy_intp' {aka 'long long int'} to 'int' inside { } [-Wnarrowing].      int init_totals[2] = {V5_n0, V1_n1};.                                        ^. C:\\Users\\sreedatta\\AppData\\Local\\Theano\\compiledir_Windows-10-10.0.19041-SP0-Intel64_Family_6_Model_140_Stepping_1_GenuineIntel-3.7.9-64\\tmp81eb_5sq\\mod.cpp:506:39: warning: narrowing conversion of 'V1_n1' from 'npy_intp' {aka 'long long int'} to 'int' inside { } [-Wnarrowing]. C:\\Users\\sreedatta\\AppData\\Local\\Theano\\compiledir_Windows-10-10.0.19041-SP0-Intel64_Family_6_Model_140_Stepping_1_GenuineIntel-3.7.9-64\\tmp81eb_5sq\\mod.cpp:521:5: warning: narrowing conversion of 'V5_stride0' from 'ssize_t' {aka 'long long int'} to 'int' inside { } [-Wnarrowing].      };.      ^. C:\\Users\\sreedatta\\AppData\\Local\\Theano\\compiledir_Windows-10-10.0.19041-SP0-Intel64_Family_6_Model_140_Stepping_1_GenuineIntel-3.7.9-64\\tmp81eb_5sq\\mod.cpp:521:5: warning: narrowing conversion of 'V1_stride0' from 'ssize_t' {aka 'long long int'} to 'int' inside { } [-Wnarrowing]. C:\\Users\\sreedatta\\AppData\\Local\\Theano\\compiledir_Windows-10-10.0.19041-SP0-Intel64_Family_6_Model_140_Stepping_1_GenuineIntel-3.7.9-64\\tmp81eb_5sq\\mod.cpp:521:5: warning: narrowing conversion of 'V1_stride1' from 'ssize_t' {aka 'long long int'} to 'int' inside { } [-Wnarrowing]. At global scope:. cc1plus.exe: warning: unrecognized command line option '-Wno-c++11-narrowing'. C:\\Users\\SREEDATTA\\AppData\\Local\\Temp\\ccjNNew1.s: Assembler messages:\r. C:\\Users\\SREEDATTA\\AppData\\Local\\Temp\\ccjNNew1.s:4410: Error: invalid register for .seh_savexmm\r. ", 'FunctionGraph(Elemwise{mul}(<TensorType(float64, col)>, <TensorType(int8, (True, True))>))')

Can one of you help?

Sree

tomicapretto commented 3 years ago

Hi @sreedat,

I'm sorry you're experiencing this unfortunate problem. I see that you've also opened https://github.com/pymc-devs/pymc3/issues/4908, where you tell that it works for some models but it fails for others. Could you confirm if Bambi works with a simple linear regression (without hierarchies)?

I'm not familiar with the problem you're having, but as far as I can understand, it seems to be a problem with Theano or PyMC3.

sreedat commented 3 years ago

@tomicapretto thanks for taking the time to get back to my post. Yes what you noted is correct. I could test Pymc3 and Bambi with simple linear regression models without levels successfully. If I attempt the multi-level / hierarchical approaches in Pymc3 or in Bambi I get the above error. So far I have removed the environment and reinstalled Anaconda from scratch and tried to get bambi to work on the multilevel models without success. This error persists.

tomicapretto commented 3 years ago

Maybe this one https://github.com/pymc-devs/pymc3/issues/4749 helps?

sreedat commented 3 years ago

Thanks @tomicapretto for the link. That was the first resource I had examined thoroughly to see how the errors can be corrected. I followed the specific installation instructions and that helped me run the Linear Regression and Stock Market examples provided in the “Pymc3 Getting Started” page. I was using the example code verbatim. The error occurs again in the third example “Coal Mine Disasters” model. My code shows that Pymc3 is correctly assigning NUTS for Continuous variables and Metropolis for the Discrete (the Count of Coal mine accidents) but yet the error still crops up. I have removed the environment and reinstalled per the specifications given in the link you shared. The error does not go away. In addition, I cannot run the example 3 and I cannot run the Pigs Growth Curves example from the Bambi documentation.

I have tested that model(Pigs Growth Curves) now on two other machines with fresh Anaconda3 installs (Windows 8.1 with Anaconda3-64 bit & Ubuntu 20.04 with Anaconda3-64bit). I get the same error. As a non-programmer, I'm lost

What really stumps me is that examples 1 & 2 run and three fails for Pymc3, and basic multi-level models model fails for Bambi.

Thanks again for your help - Sree

tomicapretto commented 3 years ago

I'm so sorry this is so frustrating.

What if you install everything via pip in the Ubuntu system?

Also, maybe Google Colab is a good alternative to your local computer while we try to find a solution for this problem...

Edit

I'm mentioning pip because that's how I usually install Bambi in my computer. I just have a conda environment where I do something like

conda create --name myenv
conda activate myenv
conda install pip
pip install bambi

and everything works fine (Ubuntu 20.04)

sreedat commented 3 years ago

@tomicapretto thanks for getting back. Across all three machines I have used pip to install both pymc3 and bambi. I just got my hands on a completely new laptop with no installs ever and has a dual Windows and Ubunto boot. I will install as advised and see if it works. Thanks for taking the time to help. I love using brms in the R eco-system and I found that bambi is a wonderful analog on the Python side. Thanks for doing what you all do in creating such tools and helping the rest of us.

Sree

sreedat commented 3 years ago

@tomicapretto I could not get Bambi to work on the new Windows 10 fresh install for the Pigs Growth Curve example. It worked in the new Ubuntu on a fresh install and then I got the same example model on Bambi working on my personal laptop with Windows 8.1 as well as on Ubuntu 20.04 LTS on this Windows 8.1 laptop. The good news is "bambi" is working, but why it is failing on Windows 10 laptops, I cannot figure out.

Thanks again for your help. - Sree

tomicapretto commented 3 years ago

@sreedat thanks for reporting all the work you're doing, I'm sure it can be valuable for others going through similar issues. I'm happy it's working now on Ubuntu.

For the Windows problem, I would wait until PyMC3 launches its v4. That version is going to use Aesara, instead of the unmaintained Theano.

sreedat commented 3 years ago

@tomicapretto thanks for the additional information regarding the version with Aesara. As one last attempt to get it to work on Windows 10, I have created an environment.yml file from the Windows 8.1 install where it is working and will test with Windows 10. I have found that when installing pymc3=3.11.2 or bambi=0.6.0, matplotlib=3.4.3 is unable to be compiled. It is breaking the entire installation process. I manually forced on Windows 8.1 to install the previous matplotlib=3.4.2. This compiles well. The issue is cropping on Windows 10 as well where '``matplotlib=3.4.3``` fails compilation.

I now have a good working environment for pymc3=3.11.2 on WIndows 10 and Windows 8.1; I have a good working pymc3=3.11.2 and bambi=0.5.0 together on Windows 8.1. I will see if the approach with the environment file will do the trick for bambi on Windows 10. If I get them to work, I will post those environment files for others to try and use.

Thanks again - Sree

sreedat commented 3 years ago

@tomicapretto My latest attempt at getting bambi to work on Windows 10 ends up with the same error Invalid register ...

Here I was testing the very basic linear regression example (not a multi-level model)

import bambi as bmb
import numpy as np
import pandas as pd

data = pd.DataFrame({
    "y": np.random.normal(size=50),
    "g": np.random.choice(["Yes", "No"], size=50),
    "x1": np.random.normal(size=50),
    "x2": np.random.normal(size=50)
})

model = bmb.Model("y ~ x1 + x2", data)
fitted = model.fit()

Here is the error (again with Theano of course - I actually tried to use Pymc3 v4 and bambi could not work with Aesara)

You can find the C code in this temporary file: C:\Users\SREEDATTA\AppData\Local\Temp\theano_compilation_error_umr4pu9y
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
C:\Users\SREEDATTA\AppData\Local\Temp/ipykernel_5520/1973983237.py in <module>
      1 model = bmb.Model("y ~ x1 + x2", data)
----> 2 fitted = model.fit()

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\bambi\models.py in fit(self, omit_offsets, **kwargs)
    220             )
    221 
--> 222         return self.backend.run(omit_offsets=omit_offsets, **kwargs)
    223 
    224     def build(self):

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\bambi\backends\pymc.py in run(self, start, method, init, n_init, omit_offsets, **kwargs)
    212                         n_init=n_init,
    213                         return_inferencedata=True,
--> 214                         **kwargs,
    215                     )
    216 

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\pymc3\sampling.py in sample(draws, step, init, n_init, start, trace, chain_idx, chains, cores, tune, progressbar, model, random_seed, discard_tuned_samples, compute_convergence_checks, callback, jitter_max_retries, return_inferencedata, idata_kwargs, mp_ctx, pickle_backend, **kwargs)
    502                 progressbar=progressbar,
    503                 jitter_max_retries=jitter_max_retries,
--> 504                 **kwargs,
    505             )
    506             if start is None:

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\pymc3\sampling.py in init_nuts(init, chains, n_init, model, random_seed, progressbar, jitter_max_retries, **kwargs)
   2185         raise ValueError(f"Unknown initializer: {init}.")
   2186 
-> 2187     step = pm.NUTS(potential=potential, model=model, **kwargs)
   2188 
   2189     return start, step

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\pymc3\step_methods\hmc\nuts.py in __init__(self, vars, max_treedepth, early_max_treedepth, **kwargs)
    166         `pm.sample` to the desired number of tuning steps.
    167         """
--> 168         super().__init__(vars, **kwargs)
    169 
    170         self.max_treedepth = max_treedepth

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\pymc3\step_methods\hmc\base_hmc.py in __init__(self, vars, scaling, step_scale, is_cov, model, blocked, potential, dtype, Emax, target_accept, gamma, k, t0, adapt_step_size, step_rand, **theano_kwargs)
     86         vars = inputvars(vars)
     87 
---> 88         super().__init__(vars, blocked=blocked, model=model, dtype=dtype, **theano_kwargs)
     89 
     90         self.adapt_step_size = adapt_step_size

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\pymc3\step_methods\arraystep.py in __init__(self, vars, model, blocked, dtype, logp_dlogp_func, **theano_kwargs)
    252 
    253         if logp_dlogp_func is None:
--> 254             func = model.logp_dlogp_function(vars, dtype=dtype, **theano_kwargs)
    255         else:
    256             func = logp_dlogp_func

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\pymc3\model.py in logp_dlogp_function(self, grad_vars, tempered, **kwargs)
   1002         varnames = [var.name for var in grad_vars]
   1003         extra_vars = [var for var in self.free_RVs if var.name not in varnames]
-> 1004         return ValueGradFunction(costs, grad_vars, extra_vars, **kwargs)
   1005 
   1006     @property

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\pymc3\model.py in __init__(self, costs, grad_vars, extra_vars, dtype, casting, compute_grads, **kwargs)
    689 
    690         if compute_grads:
--> 691             grad = tt.grad(self._cost_joined, self._vars_joined)
    692             grad.name = "__grad"
    693             outputs = [self._cost_joined, grad]

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\gradient.py in grad(cost, wrt, consider_constant, disconnected_inputs, add_names, known_grads, return_disconnected, null_gradients)
    637             assert g.type.dtype in theano.tensor.float_dtypes
    638 
--> 639     rval = _populate_grad_dict(var_to_app_to_idx, grad_dict, wrt, cost_name)
    640 
    641     for i in range(len(rval)):

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\gradient.py in _populate_grad_dict(var_to_app_to_idx, grad_dict, wrt, cost_name)
   1438         return grad_dict[var]
   1439 
-> 1440     rval = [access_grad_cache(elem) for elem in wrt]
   1441 
   1442     return rval

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\gradient.py in <listcomp>(.0)
   1438         return grad_dict[var]
   1439 
-> 1440     rval = [access_grad_cache(elem) for elem in wrt]
   1441 
   1442     return rval

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\gradient.py in access_grad_cache(var)
   1391                     for idx in node_to_idx[node]:
   1392 
-> 1393                         term = access_term_cache(node)[idx]
   1394 
   1395                         if not isinstance(term, Variable):

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\gradient.py in access_term_cache(node)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\gradient.py in <listcomp>(.0)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\gradient.py in access_grad_cache(var)
   1391                     for idx in node_to_idx[node]:
   1392 
-> 1393                         term = access_term_cache(node)[idx]
   1394 
   1395                         if not isinstance(term, Variable):

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\gradient.py in access_term_cache(node)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\gradient.py in <listcomp>(.0)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\gradient.py in access_grad_cache(var)
   1391                     for idx in node_to_idx[node]:
   1392 
-> 1393                         term = access_term_cache(node)[idx]
   1394 
   1395                         if not isinstance(term, Variable):

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\gradient.py in access_term_cache(node)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\gradient.py in <listcomp>(.0)
   1059             inputs = node.inputs
   1060 
-> 1061             output_grads = [access_grad_cache(var) for var in node.outputs]
   1062 
   1063             # list of bools indicating if each output is connected to the cost

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\gradient.py in access_grad_cache(var)
   1391                     for idx in node_to_idx[node]:
   1392 
-> 1393                         term = access_term_cache(node)[idx]
   1394 
   1395                         if not isinstance(term, Variable):

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\gradient.py in access_term_cache(node)
   1218                             )
   1219 
-> 1220                 input_grads = node.op.L_op(inputs, node.outputs, new_output_grads)
   1221 
   1222                 if input_grads is None:

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\tensor\elemwise.py in L_op(self, inputs, outs, ograds)
    562 
    563         # compute grad with respect to broadcasted input
--> 564         rval = self._bgrad(inputs, outs, ograds)
    565 
    566         # TODO: make sure that zeros are clearly identifiable

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\tensor\elemwise.py in _bgrad(self, inputs, outputs, ograds)
    666                 ret.append(None)
    667                 continue
--> 668             ret.append(transform(scalar_igrad))
    669 
    670         return ret

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\tensor\elemwise.py in transform(r)
    657                 return DimShuffle((), ["x"] * nd)(res)
    658 
--> 659             new_r = Elemwise(node.op, {})(*[transform(ipt) for ipt in node.inputs])
    660             return new_r
    661 

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\tensor\elemwise.py in <listcomp>(.0)
    657                 return DimShuffle((), ["x"] * nd)(res)
    658 
--> 659             new_r = Elemwise(node.op, {})(*[transform(ipt) for ipt in node.inputs])
    660             return new_r
    661 

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\tensor\elemwise.py in transform(r)
    657                 return DimShuffle((), ["x"] * nd)(res)
    658 
--> 659             new_r = Elemwise(node.op, {})(*[transform(ipt) for ipt in node.inputs])
    660             return new_r
    661 

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\graph\op.py in __call__(self, *inputs, **kwargs)
    251 
    252         if config.compute_test_value != "off":
--> 253             compute_test_value(node)
    254 
    255         if self.default_output is not None:

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\graph\op.py in compute_test_value(node)
    124 
    125     # Create a thunk that performs the computation
--> 126     thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=[])
    127     thunk.inputs = [storage_map[v] for v in node.inputs]
    128     thunk.outputs = [storage_map[v] for v in node.outputs]

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\graph\op.py in make_thunk(self, node, storage_map, compute_map, no_recycling, impl)
    632             )
    633             try:
--> 634                 return self.make_c_thunk(node, storage_map, compute_map, no_recycling)
    635             except (NotImplementedError, MethodNotDefined):
    636                 # We requested the c code, so don't catch the error.

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\graph\op.py in make_c_thunk(self, node, storage_map, compute_map, no_recycling)
    599                 raise NotImplementedError("float16")
    600         outputs = cl.make_thunk(
--> 601             input_storage=node_input_storage, output_storage=node_output_storage
    602         )
    603         thunk, node_input_filters, node_output_filters = outputs

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\link\c\basic.py in make_thunk(self, input_storage, output_storage, storage_map)
   1202         init_tasks, tasks = self.get_init_tasks()
   1203         cthunk, module, in_storage, out_storage, error_storage = self.__compile__(
-> 1204             input_storage, output_storage, storage_map
   1205         )
   1206 

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\link\c\basic.py in __compile__(self, input_storage, output_storage, storage_map)
   1140             input_storage,
   1141             output_storage,
-> 1142             storage_map,
   1143         )
   1144         return (

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\link\c\basic.py in cthunk_factory(self, error_storage, in_storage, out_storage, storage_map)
   1632             for node in self.node_order:
   1633                 node.op.prepare_node(node, storage_map, None, "c")
-> 1634             module = get_module_cache().module_from_key(key=key, lnk=self)
   1635 
   1636         vars = self.inputs + self.outputs + self.orphans

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\link\c\cmodule.py in module_from_key(self, key, lnk)
   1189             try:
   1190                 location = dlimport_workdir(self.dirname)
-> 1191                 module = lnk.compile_cmodule(location)
   1192                 name = module.__file__
   1193                 assert name.startswith(location)

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\link\c\basic.py in compile_cmodule(self, location)
   1548                     lib_dirs=self.lib_dirs(),
   1549                     libs=libs,
-> 1550                     preargs=preargs,
   1551                 )
   1552             except Exception as e:

C:\ProgramData\Anaconda3\envs\bampm3\lib\site-packages\theano\link\c\cmodule.py in compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module, hide_symbols)
   2545             compile_stderr = compile_stderr.replace("\n", ". ")
   2546             raise Exception(
-> 2547                 f"Compilation failed (return status={status}): {compile_stderr}"
   2548             )
   2549         elif config.cmodule__compilation_warning and compile_stderr:

Exception: ('Compilation failed (return status=1): C:\\Users\\SREEDATTA\\AppData\\Local\\Temp\\ccwFHUra.s: Assembler messages:\r. C:\\Users\\SREEDATTA\\AppData\\Local\\Temp\\ccwFHUra.s:365: Error: invalid register for .seh_savexmm\r. C:\\Users\\SREEDATTA\\AppData\\Local\\Temp\\ccwFHUra.s:367: Error: invalid register for .seh_savexmm\r. C:\\Users\\SREEDATTA\\AppData\\Local\\Temp\\ccwFHUra.s:369: Error: invalid register for .seh_savexmm\r. C:\\Users\\SREEDATTA\\AppData\\Local\\Temp\\ccwFHUra.s:371: Error: invalid register for .seh_savexmm\r. C:\\Users\\SREEDATTA\\AppData\\Local\\Temp\\ccwFHUra.s:373: Error: invalid register for .seh_savexmm\r. C:\\Users\\SREEDATTA\\AppData\\Local\\Temp\\ccwFHUra.s:375: Error: invalid register for .seh_savexmm\r. C:\\Users\\SREEDATTA\\AppData\\Local\\Temp\\ccwFHUra.s:377: Error: invalid register for .seh_savexmm\r. C:\\Users\\SREEDATTA\\AppData\\Local\\Temp\\ccwFHUra.s:379: Error: invalid register for .seh_savexmm\r. C:\\Users\\SREEDATTA\\AppData\\Local\\Temp\\ccwFHUra.s:381: Error: invalid register for .seh_savexmm\r. C:\\Users\\SREEDATTA\\AppData\\Local\\Temp\\ccwFHUra.s:383: Error: invalid register for .seh_savexmm\r. C:\\Users\\SREEDATTA\\AppData\\Local\\Temp\\ccwFHUra.s:385: Error: invalid register for .seh_savexmm\r. C:\\Users\\SREEDATTA\\AppData\\Local\\Temp\\ccwFHUra.s:387: Error: invalid register for .seh_savexmm\r. C:\\Users\\SREEDATTA\\AppData\\Local\\Temp\\ccwFHUra.s:389: Error: invalid register for .seh_savexmm\r. C:\\Users\\SREEDATTA\\AppData\\Local\\Temp\\ccwFHUra.s:391: Error: invalid register for .seh_savexmm\r. C:\\Users\\SREEDATTA\\AppData\\Local\\Temp\\ccwFHUra.s:393: Error: invalid register for .seh_savexmm\r. C:\\Users\\SREEDATTA\\AppData\\Local\\Temp\\ccwFHUra.s:395: Error: invalid register for .seh_savexmm\r. ', 'FunctionGraph(Elemwise{mul}(<TensorType(float64, (True,))>, <TensorType(int8, (True,))>))')

My adventures will continue :-) on Windows 10. It so interesting that the set-up that works with Theano-pymc on Windows 8.1 does not work with Windows 10.

sreedat commented 3 years ago

@tomicapretto I have finally solved the issue I was facing with Bambi compilation and the theano errors being generated with some guidance from @michaelosthege (one of the Pymc3 developers). It turned out that on Windows 10, my Anaconda libraries (Bambi and Pymc3) were using my mingw compilers from RTools (I use R and Anaconda for my Stats and Data Science work). I needed to set up my User PATH variables so that Pymc3 was accessing the m2w64 toolchain and its' mingw compilers. Now what is interesting is that I did not explicitly set up my User PATH on Windows 8.1 but Pymc3 and Bambi were working correctly. I still cannot figure that out. I know the entire file structure of Linux is very different from Windows and I did not need to set up anything post install for the correct compilers to be used.

I have volunteered to develop a post-installation troubleshooting guide for Pymc3 as a way to say thanks and help other users such as I. Let me know if there is something similar I can post here that would help other users. I truly believe that bambi is a wonderful tool for non-programmers and will help increase the utilization of Pymc3 among us.

If I can help with any documentation or a guide, I would love to. Most people when installing and using bambi may not realize where these errors are really originating from just as myself if they did not test pymc3 previously. Please let me know.

sreedat commented 3 years ago

@tomicapretto My models are working well now via bambi. I have one following question: How do I specify / change

  1. Tree Depth
  2. Acceptance Rate in Bambi?
tomicapretto commented 3 years ago

Hi @sreedat

It's so happy you have found the solution!

I've been thinking I could set up a section on our documentation webpage to show these kind of gotchas. I'll come back tomorrow with more precise guidelines.

About the second message, you can pass all those keywords to the .fit() method, e.g. model.fit(target_accept=0.9, max_treedepth=20). Basically, anything you would pass to regularpm.sample()can be passed tomodel.fit()` in Bambi

sreedat commented 3 years ago

@tomicapretto thanks for your patience and for taking the time to help. You have been such a huge help and bambi is what I tell all of my students and colleagues to use along with pymc3 as a majority of them are non-programmers and for them even pymc3 style specification is often a barrier to adoption.

Let me know if I can help with the documentation. Since I'm not a programmer, I cannot help in the development. I love what bambi does for non-programmers such as I, making pymc3 that much more accessible. I would like to help at least with the documentation portion.

I would like to help with documentation about post-installation testing of bambi and in adding examples with information concerning how to specify things such as target_accept & max_treedepth. As a end user, I often find very few models really work with the default target_accept=0.8. From working with rstan and brms, I know that target_accept is the first control parameter, I look to change, when divergences occur.

Thank you once again for your dedication, hard work, and passion to bring a tool such as bambi to the pymc3 user community. I have not done any work on GitHub and so I'm unfamiliar with the "how-to" of developing examples or documentation. I would love to get involved and help.

Sree

aloctavodia commented 3 years ago

@sreedat Thanks for offering to help with the documentation. Writing good documentation can be a hard task and getting help from the end-users always makes the process much easier and the result much richer.

I think a good strategy could be to have a FAQ section to centralize common issues, like installation issues or how to pass arguments to fit(). We could also have some of that content mentioned directly in the notebook examples. This is one case were redundancy is a good idea.

Additionally, we could have notebooks explaining in more details things like what divergences are, for these kind of pages we could coordinate with ArviZ (and also PyMC3) to have more centralized resources. ArviZ has a subproject of writing documentation explaining things such as convergence diagnostics. @OriolAbril, @canyon289, @roshnaeem

sreedat commented 3 years ago

@aloctavodia thanks for getting back. I would love to contribute with Installation to start with since I think for the new inexperienced users, getting a working installation of Pymc3 and Bambi on Windows will be the biggest hurdle to overcome. I sincerely believe that both Pymc3 and Bambi represent powerful and amazing tools in the Bayesian space and would love for more non-programmers and applied researchers to begin using these tools. So many of us are using both R and Python for Bayesian modeling and both of these tools and platforms work and function somewhat differently on Windows compared to Linux/Unix/MacOs. In my recent exercise, I could clearly see how I got stuck just at the installation stage, even though I have worked with R and RTools for a long time.

Your suggestion for passing arguments to fit() and explaining what the divergences are and how they are addressed by changing values of target_accept or convergence diagnostics in Notebooks would be the perfect way to illustrate to new users the use of Pymc3, Bambi, and Arviz. Additionally examples that illustrate the use of ADVI vs MH vs HMC-NUTS would also be very helpful. In the R eco-system I work with non-Bayesian packages nlme & lme4 to understand hierarchical models first before embarking on Bayesian using MH / Gibbs / HMC-NUTS. I would like to do the same for Bambi where we begin with statsmodels and then build on those concepts into Pymc3 and Bambi applications.

I will reach out to you with a installation guide first. I had posted an initial guide for installing Pymc3 (on the Github\Pymc3) under Issues as advised by @michaelosthege. If you could take a look at that and give me feedback would be great. I can easily add the piece of installing Bambi and testing it.

I have worked for a longtime in marketing research and analytics and can bring a number of real world data sets, that I have collected personally as a consultant, when creating these examples. I look forward to helping in any way I can to these wonderful projects.

tomicapretto commented 3 years ago

@sreedat I'm adding a FAQ page to our docs. If you think you can create the PR, go ahead. Otherwise, leave your installation guide here and I will add it to our docs.

Bambi docs are built with sphinx, which uses the Restructured Text format. This cheatsheet may be helpful.

Some guidelines if you want to create the PR:

Finally, it would be awesome if you could contribute real world datasets. I want to add some end-to-end examples with real data to our gallery and having yours would be great. You could simply open a PR where we can discuss how to add your data to the library, but also feel free to send me an email if you want to discuss anything before making data public.

sreedat commented 3 years ago

Thanks @tomicapretto for the notes above. What is a PR? I will begin by setting up what is needed. What were you referring to when you said "the root of the project"? Do I need to git clone the bambi repository locally to get started? These questions are likely basic, but will be helpful for me to start. I will also examine the cheat sheet. I would love for bambi to be illustrated with real world data sets.

tomicapretto commented 3 years ago

@sreedat, PR means Pull Request. It is an instance where a contributor tells the maintainers of a project to review code that he/she wants to merge into the project.

We have a CONTRIBUTING file, but these are the steps you need:

  1. Make sure you have git installed on your machine. This can help to install it. Also, the whole git guide may be helpful to get you familiar with Git and Github.
  2. Fork the project repository by clicking on the 'Fork' button near the top right of the main repository page. This creates a copy of the code under your GitHub user account.
  3. Open the console in a folder where you usually store software projects and clone your fork of the Bambi repo from your GitHub account to your local disk, and add the base repository as a remote:
git clone git@github.com:sreedat/bambi.git
cd bambi
git remote add upstream git@github.com:bambinos/bambi.git

The first line clones the repo, the seconds moves you to the root of the bambi project, and the third line tells Git that the repository in bambinos/bambi (the base) is a remote (see here for info on the upstream).

  1. Create a feature branch to hold your development changes. If the name of the branch is new-docs you can do:
git checkout -b new-docs

Always use a feature branch. It's good practice to never routinely work on the main branch of any repository.

  1. Project requirements are in requirements.txt, and libraries used for development are in requirements-dev.txt. To set up a development environment, you may run:
pip install -r requirements.txt
pip install -r requirements-dev.txt
  1. This is where you add new things to the library. In this case it would be writing content in docs/faq.rst. Then, add changed files using git add and then git commit files:
git add docs/faq.rst
git commit -m "This message describes the changes made"
  1. Push the changes to your GitHub account with:
git push -u origin new-docs
  1. Go to the GitHub web page of your fork of the Bambi repo. Click the 'Pull request' button to send your changes to the project's maintainers for review. This will send an email to me and other mantainers.
sreedat commented 3 years ago

@tomicapretto thank you for a detailed step by step process description. I will get familiar with this process in a couple of days. Beginning this Friday, I will start sharing content. I will reach out if I get stuck or have a question.

Sree