| backward | R Documentation |
Traverses the gradient tape in reverse and accumulates gradients into
tensor$grad for all leaf tensors with requires_grad = TRUE.
backward(loss)
loss |
Scalar ag_tensor |
Named environment: tensor id -> gradient matrix (for use by optimizer$step)
w <- ag_param(matrix(runif(4), 2, 2))
x <- ag_tensor(matrix(c(1, 2), 2, 1))
y <- ag_tensor(matrix(c(0, 1), 2, 1))
with_grad_tape({
out <- ag_matmul(w, x)
loss <- ag_mse_loss(out, y)
})
grads <- backward(loss)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.