Differece between bert's attention and transformer's.
B = batch size (number of sequences)
F = `from_tensor` sequence length
T = `to_tensor` sequence length
N = `num_attention_heads`
H = `size_per_head`
Hi, I'm a little confused that in your attention_layer of modelling, you seem to do linear operation for query only once. And transpose it to shape [B, N, F, H], But in the original transformer, linear operation was done on query multi times and without transposing at all. Right? Thanks!
The actual implementation of how multi-headed attention is done might be slightly different, but I believe that this is mathematically identical to the original T2T attention.
The confusion might be that this attention operation does not assume self-attention, although in the case of the BERT model we released we only used self attention. So from_tensor and to_tensor are always the same, but the code doesn't assume that. If you assume self-attention then you can just transform the input tensor 3 times to generate query, key, and value tensors.
If you assume self-attention
@jacobdevlin-google Does that mean, current BERT implementation is not using self attention?