modify chinese comment

This commit is contained in:
ly119399
2022-06-30 14:51:09 +08:00
parent 99772b1acc
commit d361c1730b

View File

@@ -51,8 +51,6 @@ class MultiheadAttention(nn.Module):
if mask is not None:
'''
mask: [batch size, num_heads, seq_len, seq_len]
mask后两维(seq_len, seq_len)矩阵来看其中有的行可能都是true(1),对应句子中<pad>位看的行
导致softmax后该行的每个位置的attn prob都为1/n而非0所以此处需重置为0
>>> F.softmax([-1e10, -100, -100])
>>> [0.00, 0.50, 0.50]