lstm_seqlabel_circuit_order_one_crf_decode_and_partition.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:neural_wfst 作者: se4u 项目源码 文件源码
def tagged_sequence_unnormalized_score_in_order_one_crf(input_tv, y, l):
    '''
    Simply sum the log-scores along the path suggested by `y` in the `input_tv`
    tensor.

    Params
    ------
    input_tv : A 3D tensor of (token, prev_pos, cur_pos) log scores.
      the input_tv also contains scores of
    y    : The true sequence that was actually followed.
    l    : The score of (EOS | tag)
    '''
    def _score_step(o, y, p_, y_):
        return ((p_ + o[y_, y]), y)
    [rval, _], _ = theano.scan(_score_step,
                               sequences=[input_tv[1:, :-1], y[1:]],
                               #sequences=[input_tv, y],
                               outputs_info=[input_tv[0, -1, y[0]], y[0]],
                               #outputs_info=[0.0, numpy.int32(-1)],
                               name='OrderOnePathMax_scan_score_step',
                               strict=True)
    return rval[-1] + l[y[-1]]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号