未验证 提交 1445103b 编写于 作者: S Sing_chan 提交者: GitHub

merge from latest develop branch, test=document_fix (#34995)

上级 5bb12853
...@@ -390,7 +390,8 @@ def monkey_patch_varbase(): ...@@ -390,7 +390,8 @@ def monkey_patch_varbase():
def item(self, *args): 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:
*args(int): The input coordinates. If it's single int, the data in the corresponding order of flattened Tensor will be returned. *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(): ...@@ -426,8 +427,6 @@ def monkey_patch_varbase():
print(x.item(2)) #3.3 print(x.item(2)) #3.3
print(x.item(0, 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() return self._getitem_from_offset(*args).item()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册