提交 78ae64eb 编写于 作者: Z zhupengyang 提交者: tensor-tang

fix argmin doc (#1263)

* fix argmin doc
test=document_preview

* test=document_preview

* fix
test=document_preview
上级 a03b81ba
......@@ -3,34 +3,49 @@
argmin
-------------------------------
.. py:function:: paddle.fluid.layers.argmin(x,axis=0)
.. py:function:: paddle.fluid.layers.argmin(x, axis=0)
**argmin**
功能计算输入张量元素中最小元素的索引,张量元素在提供的轴上
OP沿 ``axis`` 计算输入 ``x`` 的最小元素的索引
参数:
- **x** (Variable)-计算最小元素索引的输入
- **axis** (int)-计算索引的轴
- **x** (Variable) - 输入的多维 ``Tensor`` ,支持的数据类型:float32、float64、int8、int16、int32、int64。
- **axis** (int,可选) - 指定对输入Tensor进行运算的轴, ``axis`` 的有效范围是[-R, R),R是输入 ``x`` 的Rank, ``axis`` 为负时与 ``axis`` +R 等价。默认值为0。
返回:存储在输出中的张量
返回: ``Tensor`` ,数据类型int64
返回类型:变量(Variable)
返回类型:Variable
**代码示例**:
.. code-block:: python
import paddle.fluid as fluid
x = fluid.layers.data(name="x", shape=[3, 4], dtype="float32")
out = fluid.layers.argmin(x, axis=0)
out = fluid.layers.argmin(x, axis=-1)
import paddle.fluid as fluid
import numpy as np
in1 = np.array([[[5,8,9,5],
[0,0,1,7],
[6,9,2,4]],
[[5,2,4,2],
[4,7,7,9],
[1,7,0,6]]])
with fluid.dygraph.guard():
x = fluid.dygraph.to_variable(in1)
out1 = fluid.layers.argmin(x=x, axis=-1)
out2 = fluid.layers.argmin(x=x, axis=0)
out3 = fluid.layers.argmin(x=x, axis=1)
out4 = fluid.layers.argmin(x=x, axis=2)
print(out1.numpy())
# [[0 0 2]
# [1 0 2]]
print(out2.numpy())
# [[0 1 1 1]
# [0 0 0 0]
# [1 1 1 0]]
print(out3.numpy())
# [[1 1 1 2]
# [2 0 2 0]]
print(out4.numpy())
# [[0 0 2]
# [1 0 2]]
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册