powered by
This function implements a simplified version of multi-head attention for sequence data.
multihead_att(query, key, value, num_heads)
A numeric matrix representing the attention output.
A numeric matrix representing the query.
A numeric matrix representing the key.
A numeric matrix representing the value.
An integer specifying the number of attention heads.
query <- matrix(rnorm(12), nrow = 3) key <- matrix(rnorm(12), nrow = 3) value <- matrix(rnorm(12), nrow = 3) multihead_att(query, key, value, num_heads = 2)
Run the code above in your browser using DataLab