# amin¶

paddle. amin ( x, axis=None, keepdim=False, name=None ) [源代码]

## 参数¶

• x (Tensor) - Tensor，支持数据类型为 float32、float64、int32、int64，维度不超过 4 维。

• axis (int|list|tuple，可选) - 求最小值运算的维度。如果为 None，则计算所有元素的最小值并返回包含单个元素的 Tensor 变量，否则必须在 \([−x.ndim, x.ndim]\) 范围内。如果 \(axis[i] < 0\)，则维度将变为 \(x.ndim+axis[i]\)，默认值为 None。

• keepdim (bool，可选)- 是否在输出 Tensor 中保留减小的维度。如果 keepdim 为 False，结果 Tensor 的维度将比输入 Tensor 的小，默认值为 False。

• name (str，可选) - 具体用法请参见 Name，一般无需设置，默认值为 None。

## 返回¶

Tensor，在指定 axis 上进行求最小值运算的 Tensor，数据类型和输入数据类型一致。

## 代码示例¶

```>>> import paddle
>>> # data_x is a Tensor with shape [2, 4] with multiple minimum elements
>>> # the axis is a int element

>>> x = paddle.to_tensor([[0.2, 0.1, 0.1, 0.1],
...                         [0.1, 0.1, 0.6, 0.7]],
>>> # There are 5 minimum elements:
>>> # 1) amin evenly distributes gradient between these equal values,
>>> #    thus the corresponding gradients are 1/5=0.2;
>>> # 2) while min propagates gradient to all of them,
>>> #    thus the corresponding gradient are 1.
>>> result1.backward()
>>> result1
0.10000000)
[[0.        , 0.20000000, 0.20000000, 0.20000000],
[0.20000000, 0.20000000, 0.        , 0.        ]])

>>> result1_min.backward()
>>> result1_min
0.10000000)
[[0., 1., 1., 1.],
[1., 1., 0., 0.]])

>>> result2.backward()
>>> result2
[0.10000000, 0.10000000, 0.10000000, 0.10000000])
[[0.        , 0.50000000, 1.        , 1.        ],
[1.        , 0.50000000, 0.        , 0.        ]])

>>> result3.backward()
>>> result3
[0.10000000, 0.10000000])
[[0.        , 0.33333333, 0.33333333, 0.33333333],
[0.50000000, 0.50000000, 0.        , 0.        ]])

>>> result4 = paddle.amin(x, axis=1, keepdim=True)
>>> result4.backward()
>>> result4
[[0.10000000],
[0.10000000]])
[[0.        , 0.33333333, 0.33333333, 0.33333333],
[0.50000000, 0.50000000, 0.        , 0.        ]])

>>> # data_y is a Tensor with shape [2, 2, 2]
>>> # the axis is list
>>> y = paddle.to_tensor([[[0.2, 0.1], [0.1, 0.1]],
...                       [[0.1, 0.1], [0.6, 0.7]]],
>>> result5 = paddle.amin(y, axis=[1, 2])
>>> result5.backward()
>>> result5
[0.10000000, 0.10000000])
Tensor(shape=[2, 2, 2], dtype=float64, place=Place(cpu), stop_gradient=False,
[[[0.        , 0.33333333],
[0.33333333, 0.33333333]],
[[0.50000000, 0.50000000],
[0.        , 0.        ]]])

>>> result6 = paddle.amin(y, axis=[0, 1])
>>> result6.backward()
>>> result6