PyTorch torch.fmin 関数


Pytorch torch 参考手册Pytorch torch リファレンスマニュアル

torch.fminPyTorchのtorch.fminは、要素ごとに最小値を取る関数です(NaNを無視)。入力にNaNが含まれる場合、torch.minimumはNaNを返しますが、torch.fminはNaNを無視して非NaNの値を返します。

関数定義

torch.fmin(input, other)

使用例

実例

import torch

# NaNを含むテンソルを作成
x = torch.tensor([3.0, float('nan'), 4.0])
y = torch.tensor([1.0, 5.0, 2.0])

# 要素ごとに最小値を取得(NaNを無視)
result = torch.fmin(x, y)
print(result)

出力結果は次のとおりです:

tensor([1., 5., 2.])

Pytorch torch 参考手册Pytorch torch リファレンスマニュアル

その他の拡張