mask softmax的tensorflow实现
原始的tensorflow实现是通过把一个mask的位置改成一个非常小的负数,然后加到原来的向量上实现的:
adder = (1.0 - tf.cast(mask, inputs.dtype)) * (
_large_compatible_negative(inputs.dtype))
# Since we are adding it to the raw scores before the softmax, this is
# effectively the same as removing these entirely.
inputs += adder
if isinstance(self.axis, (tuple, list)):
if len(self.axis) > 1:
return tf.exp(
版权声明:
作者:lichengxin
链接:https://www.techfm.club/p/28406.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。
THE END
二维码
共有 0 条评论