R/grad_mode.R
with_no_grad.Rd
Temporarily modify gradient recording.
with_no_grad(code)
code to be executed with no gradient recording.
x <- tensor(runif(5), requires_grad = TRUE) with_no_grad({x$sub_(tensor(as.numeric(1:5)))}) x#> tensor #> -0.1445 #> -1.6950 #> -2.2636 #> -3.0590 #> -4.1390 #> [ Variable[CPUFloatType]{5} ]