gradient¶
- paddle.Tensor. gradient ( self )
-
Warning
This API will be deprecated in the future, it is recommended to use
x.grad
which returns the tensor value of the gradient.Get the Gradient of Current Tensor.
- Returns
-
Numpy value of the gradient of current Tensor
- Return type
-
ndarray
Examples
import paddle x = paddle.to_tensor(5., stop_gradient=False) y = paddle.pow(x, 4.0) y.backward() print("grad of x: {}".format(x.gradient())) # [500.]