'int' object has no attribute 'type' (pymc3)

Dear all,

The following code gives an error ‘int’ object has no attribute ‘type’ (pymc3) , because I am new in Theano based implementation in pymc3, I am not sure about the mistake. Maybe you could point it out fast. I have used the same code modified for pymc2, which worked well. Following is a snippet of the code, where some defined functions are outside this code.

%%

import pymc3 as pm
import theano.tensor as t
import theano

exp_rxn_order_CO = 0.840295
exp_rxn_order_O2 = 0.02
exp_act_barrier = 0.69 # in eV

define priors

mu --> Mean of the normal distribution

tau = 1 / (St dev)^2

@theano.compile.ops.as_op(itypes=[t.dscalar, t.dscalar, t.bscalar, t.dvector],otypes=[t.fscalar])
def rxnOrderCO(dE_CO_ads,Ea_CO_oxid,T,P):
rxnOrderCO = rxn_order_CO_corrected(T,P,dE_CO_ads,Ea_CO_oxid)
return rxnOrderCO

@theano.compile.ops.as_op(itypes=[t.dscalar, t.dscalar, t.bscalar, t.dvector],otypes=[t.fscalar])
def rxnOrderO2(dE_CO_ads,Ea_CO_oxid,T,P):
rxnOrderO2 = rxn_order_O2_corrected(T,P,dE_CO_ads,Ea_CO_oxid)
return rxnOrderO2

@theano.compile.ops.as_op(itypes=[t.dscalar, t.dscalar, t.bscalar, t.dvector],otypes=[t.fscalar])
def act_barrier(dE_CO_ads,Ea_CO_oxid,T,P):
act_barrier = apparent_barrier_corrected(T,P,dE_CO_ads,Ea_CO_oxid)
return act_barrier

with pm.Model() as model:
T = 473
P = [0.02, 0.2]
dE_CO_ads = pm.Normal(‘dE_CO_ads’, mu=0, tau=1/0.12)
Ea_CO_oxid = pm.Normal(‘Ea_CO_oxid’, mu=0.60, tau=1/0.1
2)

with pm.Model() as model:

rxnOrderCO = pm.Deterministic("rxnOrderCO", 
rxnOrderCO(dE_CO_ads,Ea_CO_oxid,T,P))    

#define likelihood
rxnOrder_CO = pm.Normal('rxnOrder_CO',mu=rxnOrderCO, tau = 1/0.1**2, value = exp_rxn_order_CO, observed=True)
rxnOrder_O2 = pm.Normal('rxnOrder_O2',mu=rxnOrderO2, tau = 1/0.1**2, value = exp_rxn_order_O2, observed=True)
actBarrier = pm.Normal('actBarrier',mu=act_barrier, tau = 1/0.1**2, value = exp_act_barrier, observed=True)
#%% Bayesian inference

Following is the error trace:

AttributeError Traceback (most recent call last)
in
1 with pm.Model() as model:
2
----> 3 rxnOrderCO = pm.Deterministic(“rxnOrderCO”, rxnOrderCO(dE_CO_ads,Ea_CO_oxid,T,P))
4
5 #define likelihood

C:\ProgramData\Anaconda3\lib\site-packages\theano\gof\op.py in call(self, *inputs, **kwargs)
613 “”"
614 return_list = kwargs.pop(‘return_list’, False)
–> 615 node = self.make_node(*inputs, **kwargs)
616
617 if config.compute_test_value != ‘off’:

C:\ProgramData\Anaconda3\lib\site-packages\theano\gof\op.py in make_node(self, *inputs)
981 raise ValueError(“We expected %d inputs but got %d.” %
982 (len(self.itypes), len(inputs)))
–> 983 if not all(inp.type == it for inp, it in zip(inputs, self.itypes)):
984 raise TypeError(
985 "We expected inputs of types ‘%s’ but got types ‘%s’ " %

C:\ProgramData\Anaconda3\lib\site-packages\theano\gof\op.py in (.0)
981 raise ValueError(“We expected %d inputs but got %d.” %
982 (len(self.itypes), len(inputs)))
–> 983 if not all(inp.type == it for inp, it in zip(inputs, self.itypes)):
984 raise TypeError(
985 "We expected inputs of types ‘%s’ but got types ‘%s’ " %

AttributeError: ‘int’ object has no attribute ‘type’

I guess this has to do with the theono variables defined decorator for the functions. Thanks in advance.

What happens when you apply theano.tensor.as_tensor_variable to the second argument of your deterministic node?