megengine.core.tensor.array_method.ArrayMethodMixin.min

ArrayMethodMixin.min(axis=None, keepdims=False)[源代码]

Returns the min value of each row of the input tensor in the given dimension axis.

If axis is a list of axises, reduce over all of them. If keepdims is True, the shape of output tensor is the same as the input tensor, except in the dimension(s) axis where it is of size 1. Otherwise, axis is squeezed (see squeeze).

参数
  • axis – the dimension or dimensions to reduce.

  • keepdims (bool) – 输出张量是否保留了轴 ndim 。

返回

输出张量。

实际案例

from megengine import tensor
a = tensor([False, True, True, False])
b = tensor([1.0, 2.0, 3.0, 4.0])
print(a.min().numpy())
print(b.min().numpy())

输出:

False
1.0