Skip to content

Commit

Permalink
隐藏的信息泄漏风险
Browse files Browse the repository at this point in the history
  • Loading branch information
bojone authored Apr 29, 2022
1 parent 97b507d commit 5572ed4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bert4keras/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ def attention_normalize(a, axis=-1, method='softmax'):
if method == 'squared_relu':
return K.relu(a)**2 / l
elif method == 'softmax_plus':
return K.softmax(a * K.log(l) / np.log(512), axis=axis)
scale = K.log(l) / np.log(512) * mask + 1 - mask
return K.softmax(a * scale, axis=axis)
return a


Expand Down

0 comments on commit 5572ed4

Please sign in to comment.