Attention weights after dropout
×Training dropout acts on the probabilities before value retrieval; at evaluation this equals A.
- shape
- head i [B batch, T queries, T keys] all heads [B batch, 12 heads, T queries, T keys]
Training only, in the maintained code: dropout zeroes some weights and rescales the rest, so a row need not sum to one (modeling_gpt2.py 67). At evaluation, and in the released OpenAI code, .
Sources
In codeattn_weights · modeling_gpt2.py 67
Incoming transform evidence
The maintained eager attention path normalizes scores, applies training-dependent dropout, and multiplies the resulting weights by values.
modeling_gpt2.py 63–69 ↗ · huggingface/transformers @ 71c6f699ac9b
Excerpt
attn_weights = nn.functional.softmax(attn_weights, dim=-1)
# Downcast (if necessary) back to V's dtype (if in mixed-precision) -- No-Op otherwise
attn_weights = attn_weights.type(value.dtype)
attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)
attn_output = torch.matmul(attn_weights, value)