评价此页

torch.fmin#

torch.fmin(input, other, *, out=None) Tensor#

计算 inputother 的逐元素最小值。

This is like torch.minimum() except it handles NaNs differently: if exactly one of the two elements being compared is a NaN then the non-NaN element is taken as the minimum. Only if both elements are NaN is NaN propagated.

This function is a wrapper around C++’s std::fmin and is similar to NumPy’s fmin function.

Supports broadcasting to a common shape, type promotion, and integer and floating-point inputs.

参数
  • input (Tensor) – 输入张量。

  • other (Tensor) – 第二个输入张量

关键字参数

out (Tensor, optional) – 输出张量。

示例

>>> a = torch.tensor([2.2, float('nan'), 2.1, float('nan')])
>>> b = torch.tensor([-9.3, 0.1, float('nan'), float('nan')])
>>> torch.fmin(a, b)
tensor([-9.3000, 0.1000, 2.1000,    nan])