未验证 提交 97a20d75 编写于 作者: Z Zhong Hui 提交者: GitHub

[DOC] refine arg_min_max doc. test=document_fix (#40803)

上级 d9a41fc4
...@@ -123,7 +123,7 @@ def argmax(x, axis=None, keepdim=False, dtype="int64", name=None): ...@@ -123,7 +123,7 @@ def argmax(x, axis=None, keepdim=False, dtype="int64", name=None):
axis(int, optional): Axis to compute indices along. The effective range axis(int, optional): Axis to compute indices along. The effective range
is [-R, R), where R is x.ndim. when axis < 0, it works the same way is [-R, R), where R is x.ndim. when axis < 0, it works the same way
as axis + R. Default is None, the input `x` will be into the flatten tensor, and selecting the min value index. as axis + R. Default is None, the input `x` will be into the flatten tensor, and selecting the min value index.
keepdim(bool, optional): Keep the axis that selecting max. The defalut value is False. keepdim(bool, optional): Whether to keep the given axis in output. If it is True, the dimensions will be same as input x and with size one in the axis. Otherwise the output dimentions is one fewer than x since the axis is squeezed. Default is False.
dtype(str|np.dtype, optional): Data type of the output tensor which can dtype(str|np.dtype, optional): Data type of the output tensor which can
be int32, int64. The default value is 'int64', and it will be int32, int64. The default value is 'int64', and it will
return the int64 indices. return the int64 indices.
...@@ -144,12 +144,15 @@ def argmax(x, axis=None, keepdim=False, dtype="int64", name=None): ...@@ -144,12 +144,15 @@ def argmax(x, axis=None, keepdim=False, dtype="int64", name=None):
[6,9,2,4]]) [6,9,2,4]])
out1 = paddle.argmax(x) out1 = paddle.argmax(x)
print(out1) # 2 print(out1) # 2
out2 = paddle.argmax(x, axis=1) out2 = paddle.argmax(x, axis=0)
print(out2) print(out2)
# [2 3 1] # [2, 2, 0, 1]
out3 = paddle.argmax(x, axis=-1) out3 = paddle.argmax(x, axis=-1)
print(out3) print(out3)
# [2 3 1] # [2, 3, 1]
out4 = paddle.argmax(x, axis=0, keepdim=True)
print(out4)
# [[2, 2, 0, 1]]
""" """
if axis is not None and not isinstance(axis, int): if axis is not None and not isinstance(axis, int):
raise TypeError( raise TypeError(
...@@ -200,7 +203,7 @@ def argmin(x, axis=None, keepdim=False, dtype="int64", name=None): ...@@ -200,7 +203,7 @@ def argmin(x, axis=None, keepdim=False, dtype="int64", name=None):
axis(int, optional): Axis to compute indices along. The effective range axis(int, optional): Axis to compute indices along. The effective range
is [-R, R), where R is x.ndim. when axis < 0, it works the same way is [-R, R), where R is x.ndim. when axis < 0, it works the same way
as axis + R. Default is None, the input `x` will be into the flatten tensor, and selecting the min value index. as axis + R. Default is None, the input `x` will be into the flatten tensor, and selecting the min value index.
keepdim(bool, optional): Keep the axis that selecting min. The defalut value is False. keepdim(bool, optional): Whether to keep the given axis in output. If it is True, the dimensions will be same as input x and with size one in the axis. Otherwise the output dimentions is one fewer than x since the axis is squeezed. Default is False.
dtype(str): Data type of the output tensor which can dtype(str): Data type of the output tensor which can
be int32, int64. The default value is 'int64', and it will be int32, int64. The default value is 'int64', and it will
return the int64 indices. return the int64 indices.
...@@ -221,12 +224,15 @@ def argmin(x, axis=None, keepdim=False, dtype="int64", name=None): ...@@ -221,12 +224,15 @@ def argmin(x, axis=None, keepdim=False, dtype="int64", name=None):
[6,9,2,4]]) [6,9,2,4]])
out1 = paddle.argmin(x) out1 = paddle.argmin(x)
print(out1) # 4 print(out1) # 4
out2 = paddle.argmin(x, axis=1) out2 = paddle.argmin(x, axis=0)
print(out2) print(out2)
# [0 0 2] # [1, 1, 1, 2]
out3 = paddle.argmin(x, axis=-1) out3 = paddle.argmin(x, axis=-1)
print(out3) print(out3)
# [0 0 2] # [0, 0, 2]
out4 = paddle.argmin(x, axis=0, keepdim=True)
print(out4)
# [[1, 1, 1, 2]]
""" """
if axis is not None and not isinstance(axis, int): if axis is not None and not isinstance(axis, int):
raise TypeError( raise TypeError(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册