Transformers, Pytorch, Machine Learning, Deep Dives, Data Science.
self.num_heads}), got {x.size()}" assert x.size(3) == self.hidden_dim // self.num_heads def scaled_dot_product_attention( self, query, key, value, attention_mask=None, key_padding_mask=None): """ query : tensor of shape (batch_size, num_heads, query_sequence_length, hidden_dim//num_heads) key :