Skip to content

Commit

Permalink
add more info to tensor.grad warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
MingMingShangTian committed Jul 20, 2021
1 parent 3a5f1f2 commit 08232b2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion python/paddle/fluid/dygraph/varbase_patch_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,10 @@ def grad(self):
# Tensor(shape=[1], dtype=float32, place=CUDAPlace(0), stop_gradient=False, [500.])
"""
msg = "tensor.grad will return the tensor value of the gradient."
msg = 'tensor.grad will return the tensor value of the gradient.' \
' This is an incompatible upgrade for tensor.grad API. ' \
' It\'s return type changes from numpy.ndarray in version 2.0 to paddle.Tensor in version 2.1.0. ' \
' If you want to get the numpy value of the gradient, you can use :code:`x.grad.numpy()`'
warning_msg = "\033[93m\nWarning:\n%s \033[0m" % (msg)
# ensure ANSI escape sequences print correctly in cmd and powershell
if sys.platform.lower() == 'win32':
Expand Down

1 comment on commit 08232b2

@paddle-bot-old
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congratulation! Your pull request passed all required CI. You could ask reviewer(s) to approve and merge. 🎉

Please sign in to comment.