我是PyMC3的新手 这里有一些PyMC2 - 我需要做一些特定的事情,比如在Theano中编译将其转换为PyMC3代码吗?
@pymc.deterministic
def away_theta(home_team=home_team,
away_team=away_team,
home=home,
atts=atts,
defs=defs,
intercept=intercept):
return np.exp(intercept +
atts[away_team] +
defs[home_team])
我收到类似
的错误AsTensorError: ('Cannot convert home_theta to TensorType', <class 'pymc.PyMCObjects.Deterministic'>)
答案 0 :(得分:3)
是的,确定性转换需要是pymc3中的theano表达式。因此,不要使用np.exp,而是使用theano.tensor.exp:
import theano.tensor as T
import pymc3 as pm
with Model():
...
regression = pm.Deterministic('regression', T.exp(intercept + atts[away_team] + defs[home_team]))
...