昇思25天学习打卡营第17天|LSTM+CRF

BIOE label: 

B start of an entity; O background; I other parts of an entity

We first compute a certain score.

def compute_score(emissions, tags, seq_ends, mask, trans, start_trans, end_trans):
    seq_length, batch_size = tag.shape
    mask = mask.astype(emissions.dtype)
    score = start_trans[tags[0]]
    score += emissions[0, mnp.arange(batch_size),tags[0]]
    for i in range(1, seq_length):
        score += trans[tags[i-1], tags[i]] * mask[i]
        score  += emissions[i, mnp.arange(batch_size), tags[i]] * mask[i]
    last_tags = tags[seq_ends, mnp.arange(batch_size)]
    score += end_trans[last_tags]
    return score

how to understand the score? 

Just two thing:

 1. When we consider a input seq: x = {x1, x2, x3...} and 

a label y = {y1, y2, y3 ...} correspondingly, there exists a transportation probablity 

where score(x, y) can represent the probablity  from x to generate y.

2. Okay, so we need to acculumate probablity of x_i to y_i, and y_(i-1) to y_i since it is important to generate a reasonable next label after one has been generated.

so the former probablity is called emission probablity \Psi_{EMIT}, and the next is called transportation probablity \Psi_{TRANS}, and we can define a kind of score by:

Score(x,y) = \sum_i log \Psi_{EMIT}(x_i \to y_i ) + log\Psi_{TRANS}(y_{i-1} \to y_i) 

Next we define  a concept called normalizer., which represents the denominator of the formula below:

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值