From 1445103b669d6f4d507dca3804b1bfe57673a96e Mon Sep 17 00:00:00 2001 From: Sing_chan <51314274+betterpig@users.noreply.github.com> Date: Tue, 7 Sep 2021 14:22:59 +0800 Subject: [PATCH] merge from latest develop branch, test=document_fix (#34995) --- python/paddle/fluid/dygraph/varbase_patch_methods.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/python/paddle/fluid/dygraph/varbase_patch_methods.py b/python/paddle/fluid/dygraph/varbase_patch_methods.py index 102dcd43622..83e7d0ae1e0 100644 --- a/python/paddle/fluid/dygraph/varbase_patch_methods.py +++ b/python/paddle/fluid/dygraph/varbase_patch_methods.py @@ -390,7 +390,8 @@ def monkey_patch_varbase(): def item(self, *args): """ - Convert one element Tensor to a Python scalar. + Convert element at specific position in Tensor into Python scalars. If the position is not specified, the Tensor must be a + single-element Tensor. Args: *args(int): The input coordinates. If it's single int, the data in the corresponding order of flattened Tensor will be returned. @@ -426,8 +427,6 @@ def monkey_patch_varbase(): print(x.item(2)) #3.3 print(x.item(0, 2)) #3.3 - x = paddle.to_tensor([1, 2]) - x.item() #ValueError: only one element tensor can be converted to Python scalar when no input coordinates. """ return self._getitem_from_offset(*args).item() -- GitLab