无法了解CRF前进的分区功能

时间:2019-10-16 05:31:35

标签: tensorflow crf

据说,为了“有效地计算分区功能”,请在日志空间中使用正向计算。 但是我对formula described in this picture的等效性感到困惑 (尤其是使用日志空间,引用https://towardsdatascience.com/implementing-a-linear-chain-conditional-random-field-crf-in-pytorch-16b0b9c4b4ea),它与tf.contrib.crf.CrfForwardRnnCell中的代码完全匹配。 有人可以帮忙解释一下吗?我会很感激的!

这是tf代码:

state = array_ops.expand_dims(state, 2)

# This addition op broadcasts self._transitions_params along the zeroth
# dimension and state along the second dimension. This performs the
# multiplication of previous alpha values and the current binary potentials
# in log space.
transition_scores = state + self._transition_params
new_alphas = inputs + math_ops.reduce_logsumexp(transition_scores, [1])

# Both the state and the output of this RNN cell contain the alphas values.
# The output value is currently unused and simply satisfies the RNN API.
# This could be useful in the future if we need to compute marginal
# probabilities, which would require the accumulated alpha values at every
# time step.
return new_alphas, new_alphas

0 个答案:

没有答案