How can I normalize after masking?
Suppose I have a tensor like [0.6, 0.7, 0.4] and a mask like: [1, 0,0] How can I normalize it to: [1,0,0] my try: normalized_attn_scores = F.softmax(attn_scores, 1) normalized_attn_scores = normalized_attn_scores.mul(attn_mask) But it doesn’t produce the desired output >Solution : You can normalize after masking by dividing the masked tensor by its sum, like this:… Read More How can I normalize after masking?