我试图理解C++到Python接口:
在第170行的g2p.py中有这样一个代码(为清楚起见,已清理):
nBest = translator.nBestInit(left)
logLik, result = translator.nBestNext(nBest)
posterior = math.exp(logLik - nBest.logLikTotal) // ***This is the line in question***
print('%f' % (posterior))
它使用第759行的sequitur.py:
def nBestInit(self, left):
left = self.sequitur.leftInventory.parse(left)
result = self.translator.nBestInit(left)
result.thisown = True
result.logLikBest = self.translator.nBestBestLogLik(result)
result.logLikTotal = self.translator.nBestTotalLogLik(result)
return result
def nBestNext(self, nBestContext):
logLik, joint = self.translator.nBestNext(nBestContext)
joint = self.unpackJoint(joint)
left, right = self.jointToLeftRight(joint)
return logLik, right
在这个脚本中,LogLik是在Probability.hh和translator函数中定义的
在Translation.cc中。nBestTotalLogLik
&;nBestNext
都返回类类型LogProbability
。LogProbability
有各种重载,其中非重载返回数字类型,例如:
inline LogProbability operator-(const LogProbability &lhs, const LogProbability &rhs)
我的问题是,在第math.exp(logLik - nBest.logLikTotal)
行中,表达式logLik - nBest.logLikTotal
如何计算为exp()要处理的数值?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐