# megengine.functional.minimum¶

minimum(x, y)[源代码]

Element-wise minimum of tensor elements.

Compare two tensors and returns a new tensor containing the element-wise minima. If one of the elements being compared is a NaN, then that element is returned. If both elements are NaNs then the first is returned.

• x – input tensor. Should have a numeric data type.

• y – input tensor. Should have the same data type as $$x$$.

a tensor containing the element-wise minima. The returned tensor must have the same data type as $$x$$.

>>> F.minimum(1, 2)
Tensor(1, dtype=int32, device=xpux:0)


Element-wise minimum:

>>> x = Tensor([1, 2, 3, 4])
>>> y = Tensor([4, 3, 2, 1])
>>> F.minimum(x, y)
Tensor([1 2 2 1], dtype=int32, device=xpux:0)


>>> x = Tensor([1, 2, 3, 4])