diff --git a/python/paddle/base/dygraph/math_op_patch.py b/python/paddle/base/dygraph/math_op_patch.py index 1a73e6b5e9ae0..80108f4ed65e9 100644 --- a/python/paddle/base/dygraph/math_op_patch.py +++ b/python/paddle/base/dygraph/math_op_patch.py @@ -85,14 +85,15 @@ def astype(self, dtype): Examples: .. code-block:: python - import paddle - import numpy as np - - original_tensor = paddle.ones([2, 2]) - print("original tensor's dtype is: {}".format(original_tensor.dtype)) - new_tensor = original_tensor.astype('float32') - print("new tensor's dtype is: {}".format(new_tensor.dtype)) - + >>> import paddle + >>> import numpy as np + + >>> original_tensor = paddle.ones([2, 2]) + >>> print("original tensor's dtype is: {}".format(original_tensor.dtype)) + original tensor's dtype is: paddle.float32 + >>> new_tensor = original_tensor.astype('float32') + >>> print("new tensor's dtype is: {}".format(new_tensor.dtype)) + new tensor's dtype is: paddle.float32 """ if not isinstance(dtype, core.VarDesc.VarType): dtype = convert_np_dtype_to_dtype_(dtype)