ADVI example failing to run

Good morning,

I just tried to execute the following example notebook on my Mac and the ADVI code is failing to execute. In particular, cell 13 which contains

with model:
    advi_fit = pm.fit(method=pm.ADVI(), n=30000,
                      more_replacements=map_tensor_batch)

returns with

ERROR (theano.gof.opt): Optimization failure due to: constant_folding
ERROR (theano.gof.opt): node: Elemwise{log,no_inplace}(TensorConstant{(1, 1) of ..4309189535})
ERROR (theano.gof.opt): TRACEBACK:
ERROR (theano.gof.opt): Traceback (most recent call last):
  File "/Users/cpd/anaconda/envs/DataGuild/lib/python3.7/site-packages/theano/gof/opt.py", line 2034, in process_node
    replacements = lopt.transform(node)
  File "/Users/cpd/anaconda/envs/DataGuild/lib/python3.7/site-packages/theano/tensor/opt.py", line 6516, in constant_folding
    no_recycling=[], impl=impl)
  File "/Users/cpd/anaconda/envs/DataGuild/lib/python3.7/site-packages/theano/gof/op.py", line 955, in make_thunk
    no_recycling)
  File "/Users/cpd/anaconda/envs/DataGuild/lib/python3.7/site-packages/theano/gof/op.py", line 858, in make_c_thunk
    output_storage=node_output_storage)
  File "/Users/cpd/anaconda/envs/DataGuild/lib/python3.7/site-packages/theano/gof/cc.py", line 1217, in make_thunk
    keep_lock=keep_lock)
  File "/Users/cpd/anaconda/envs/DataGuild/lib/python3.7/site-packages/theano/gof/cc.py", line 1157, in __compile__
    keep_lock=keep_lock)
  File "/Users/cpd/anaconda/envs/DataGuild/lib/python3.7/site-packages/theano/gof/cc.py", line 1624, in cthunk_factory
    key=key, lnk=self, keep_lock=keep_lock)
  File "/Users/cpd/anaconda/envs/DataGuild/lib/python3.7/site-packages/theano/gof/cmodule.py", line 1189, in module_from_key
    module = lnk.compile_cmodule(location)
  File "/Users/cpd/anaconda/envs/DataGuild/lib/python3.7/site-packages/theano/gof/cc.py", line 1527, in compile_cmodule
    preargs=preargs)
  File "/Users/cpd/anaconda/envs/DataGuild/lib/python3.7/site-packages/theano/gof/cmodule.py", line 2411, in compile_str
    (status, compile_stderr.replace('\n', '. ')))
Exception: ("Compilation failed (return status=1): /Users/cpd/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.7.2-64/tmpyslfy58x/mod.cpp:360:27: error: non-constant-expression cannot be narrowed from type 'npy_intp' (aka 'long') to 'int' in initializer list [-Wc++11-narrowing].     int init_totals[2] = {V1_n0, V1_n1};.                           ^~~~~. /Users/cpd/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.7.2-64/tmpyslfy58x/mod.cpp:360:27: note: insert an explicit cast to silence this issue.     int init_totals[2] = {V1_n0, V1_n1};.                           ^~~~~.                           static_cast<int>( ). /Users/cpd/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.7.2-64/tmpyslfy58x/mod.cpp:360:34: error: non-constant-expression cannot be narrowed from type 'npy_intp' (aka 'long') to 'int' in initializer list [-Wc++11-narrowing].     int init_totals[2] = {V1_n0, V1_n1};.                                  ^~~~~. /Users/cpd/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.7.2-64/tmpyslfy58x/mod.cpp:360:34: note: insert an explicit cast to silence this issue.     int init_totals[2] = {V1_n0, V1_n1};.                                  ^~~~~.                                  static_cast<int>( ). /Users/cpd/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.7.2-64/tmpyslfy58x/mod.cpp:373:1: error: non-constant-expression cannot be narrowed from type 'ssize_t' (aka 'long') to 'int' in initializer list [-Wc++11-narrowing]. V1_stride0, V1_stride1. ^~~~~~~~~~. /Users/cpd/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.7.2-64/tmpyslfy58x/mod.cpp:373:1: note: insert an explicit cast to silence this issue. V1_stride0, V1_stride1. ^~~~~~~~~~. static_cast<int>( ). /Users/cpd/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.7.2-64/tmpyslfy58x/mod.cpp:373:13: error: non-constant-expression cannot be narrowed from type 'ssize_t' (aka 'long') to 'int' in initializer list [-Wc++11-narrowing]. V1_stride0, V1_stride1.             ^~~~~~~~~~. /Users/cpd/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.7.2-64/tmpyslfy58x/mod.cpp:373:13: note: insert an explicit cast to silence this issue. V1_stride0, V1_stride1.             ^~~~~~~~~~.             static_cast<int>( ). 4 errors generated.. ", '[Elemwise{log,no_inplace}(TensorConstant{(1, 1) of ..4309189535})]')

Any thoughts about what is going on here and how I might get around this?

Thanks!

Chris

I cannot reproduce your error - maybe try upgrading your environments?

1 Like

Will do!