diff --git a/python/paddle/fluid/framework.py b/python/paddle/fluid/framework.py index 5b9dd8693190d1c9a6a71cc6bc6e6acf2a06aa6f..dc69df4076749f6a51e215c047d5150fb314f854 100644 --- a/python/paddle/fluid/framework.py +++ b/python/paddle/fluid/framework.py @@ -408,7 +408,8 @@ class Variable(object): self._ivar._run_backward() def _gradient(self): - return np.array(self._ivar._grad_value()) + new_ivar = self._ivar._grad_ivar._copy_to(core.CPUPlace(), True) + return np.array(new_ivar.value().get_tensor()) def _clear_gradient(self): self._ivar._clear_gradient()