| with_grad_tape | R Documentation |
Records all ag_* operations inside expr for later backward().
When the default device is "gpu", the ggml context is reset at the
start of each tape.
with_grad_tape(expr)
expr |
Expression to evaluate under gradient tape |
Value of last expression in expr (invisibly)
w <- ag_param(matrix(c(1, 0, 0, 1), 2, 2))
x <- ag_tensor(matrix(c(1, 2), 2, 1))
y <- ag_tensor(matrix(c(1, 2), 2, 1))
with_grad_tape({
out <- ag_matmul(w, x)
loss <- ag_mse_loss(out, y)
})
backward(loss)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.