Dear All,
I finished writing my forward model for pymc model using theano. This is my preliminary project and once it’s get done accurately, I can move forward to my main project. I got no error in the section of pymc_model but further sampling takes too much time and return with error. Considering my current knowledge about PyMc3, I have no clue how can I improve my model. Here I am posting the error message and also attaching my code.
Description: Main_code along with the code for forward model and pymc model. Please run Main_Code.
I am looking for your kind suggestions. Please help me to improve the code pymc_forward_model.
Thanking you
Sincerely,
mahak
Attached File
Main_Code.py (1.6 KB)
Forward_Model.py (3.9 KB)
pymc_forward_model.py (4.2 KB)
Output Error
ERROR (theano.gof.opt): Optimization failure due to: local_mul_zero
ERROR (theano.gof.opt): node: Elemwise{mul,no_inplace}(TensorConstant{(1, 1) of -1.0}, Elemwise{add,no_inplace}.0)
ERROR (theano.gof.opt): TRACEBACK:
ERROR (theano.gof.opt): Traceback (most recent call last):
File “C:\Users\CT\AppData\Local\Continuum\anaconda3\lib\site-packages\theano\gof\opt.py”, line 2034, in process_node
replacements = lopt.transform(node)
File “C:\Users\CT\AppData\Local\Continuum\anaconda3\lib\site-packages\theano\tensor\opt.py”, line 5811, in local_mul_zero
value = get_scalar_constant_value(i)
File “C:\Users\CT\AppData\Local\Continuum\anaconda3\lib\site-packages\theano\tensor\basic.py”, line 511, in get_scalar_constant_value
v.owner.op.perform(v.owner, const, ret)
File “C:\Users\CT\AppData\Local\Continuum\anaconda3\lib\site-packages\theano\tensor\elemwise.py”, line 718, in perform
super(Elemwise, self).perform(node, inputs, output_storage)
File “C:\Users\CT\AppData\Local\Continuum\anaconda3\lib\site-packages\theano\gof\op.py”, line 778, in perform
“Did you used Theano flags mode=FAST_COMPILE?”
theano.gof.utils.MethodNotDefined: (‘perform’, <class ‘theano.tensor.elemwise.Elemwise’>, ‘Elemwise’, ‘Did you used Theano flags mode=FAST_COMPILE? You can use optimizer=fast_compile instead.’)
Sequential sampling (2 chains in 1 job)
HamiltonianMC: [sigma, Tens, Dip_s, Stk_s, Wid, DIP, Azim, Depth, N, E, Len]
0%| | 103/52000 [00:30<1:19:03, 10.94it/s]
Traceback (most recent call last):
File “invert_Okada.py”, line 92, in
trace = pm.sample(50000, tune=2000, init=‘none’, step=step, cores=1)
File “C:\Users\CT\AppData\Local\Continuum\anaconda3\lib\site-packages\pymc3\sampling.py”, line 459, in sample
trace = _sample_many(**sample_args)
File “C:\Users\CT\AppData\Local\Continuum\anaconda3\lib\site-packages\pymc3\sampling.py”, line 505, in _sample_many
step=step, random_seed=random_seed[i], **kwargs)
File “C:\Users\CT\AppData\Local\Continuum\anaconda3\lib\site-packages\pymc3\sampling.py”, line 549, in _sample
for it, strace in enumerate(sampling):
File “C:\Users\CT\AppData\Local\Continuum\anaconda3\lib\site-packages\tqdm_tqdm.py”, line 1022, in iter
for obj in iterable:
File “C:\Users\CT\AppData\Local\Continuum\anaconda3\lib\site-packages\pymc3\sampling.py”, line 645, in _iter_sample
point, states = step.step(point)
File “C:\Users\CT\AppData\Local\Continuum\anaconda3\lib\site-packages\pymc3\step_methods\arraystep.py”, line 247, in step
apoint, stats = self.astep(array)
File “C:\Users\CT\AppData\Local\Continuum\anaconda3\lib\site-packages\pymc3\step_methods\hmc\base_hmc.py”, line 135, in astep
self.potential.raise_ok(self._logp_dlogp_func._ordering.vmap)
File “C:\Users\CT\AppData\Local\Continuum\anaconda3\lib\site-packages\pymc3\step_methods\hmc\quadpotential.py”, line 231, in raise_ok
raise ValueError(’\n’.join(errmsg))
ValueError: Mass matrix contains zeros on the diagonal.
The derivative of RV sigma_log__
.ravel()[0] is zero.
The derivative of RV Tens_interval__
.ravel()[0] is zero.
The derivative of RV Dip_s_interval__
.ravel()[0] is zero.
The derivative of RV Stk_s_interval__
.ravel()[0] is zero.
The derivative of RV Wid_interval__
.ravel()[0] is zero.
The derivative of RV DIP_interval__
.ravel()[0] is zero.
The derivative of RV Azim_interval__
.ravel()[0] is zero.
The derivative of RV Depth_interval__
.ravel()[0] is zero.
The derivative of RV N_interval__
.ravel()[0] is zero.
The derivative of RV E_interval__
.ravel()[0] is zero.
The derivative of RV Len_interval__
.ravel()[0] is zero.