| ag_gather | R Documentation |
out[1, j] = x[index[j] + 1, j]: the log-probability of the action
taken in sample j, for example. Differentiable in x; the gradient of
column j lands on the picked row only.
ag_gather(x, index)
x |
ag_tensor or numeric matrix, |
index |
Integer-valued vector of length |
Built as colSums(x * onehot(index)), so the graph backward covers it
with no rule of its own. The one-hot is [n, batch] and is uploaded on
every call: cheap for tens of classes (games), wasteful for thousands –
there a dedicated op with an I32 index tensor is the right tool (TODO.md).
ag_tensor [1, batch].
ag_gather(matrix(1:6 + 0, 3, 2), c(2L, 0L)) # 3 4
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.