View source: R/compute_attention.R
computeattention | R Documentation |
Compute global attention weights and context vectors for time series
computeattention(series)
series |
Numeric vector containing the time series of length n |
List containing:
attention_weights |
n × n matrix where entry (i,j) represents the attention weight of time j on time i. Only entries j <= i are non-zero (causal attention). |
context_vectors |
Vector of length n where each entry i is the weighted sum of all values up to time i, using the attention weights. |
# For a series of length 5
series <- c(1, 2, 3, 4, 5)
result <- computeattention(series)
# attention_weights will be 5x5 matrix
# context_vectors will be length 5
dim(result$attention_weights) # [1] 5 5
length(result$context_vectors) # [1] 5
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.