(self, h, attn_vec, residual=True)
return output
Post-attention processing.
Post-attention processing.
Post - attention processing .
def post_attention(self, h, attn_vec, residual=True):
        """Post-attention processing."""
        # post-attention projection (back to `d_model`)
        attn_out = torch.einsum('ibnd,hnd->ibh', attn_vec, self.o)

        attn_out = self.dropout(attn_out)
        if residual:
            attn_out = attn_out + h
        output = self.layer_norm(attn_out)

        return output
def post_attention ( self , h , attn_vec , residual = True ) : # post-attention projection (back to `d_model`) attn_out = torch . einsum ( 'ibnd,hnd->ibh' , attn_vec , self . o ) attn_out = self . dropout ( attn_out ) if residual : attn_out = attn_out + h output = self . layer_norm ( attn_out ) return output