PyTorch torch.greater 関数


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

torch.greaterPyTorchにおいて、要素ごとに大なり比較を行う関数です。最初のテンソルの要素が2番目のテンソルの対応する要素より大きい位置でTrueとなるテンソルを返します。

関数定義

torch.greater(input, other)

使用例

例

import torch

# 2つのテンソルを作成
x = torch.tensor([3, 5, 2])
y = torch.tensor([2, 4, 2])

# 要素ごとに大なりを比較
result = torch.greater(x, y)
print(result)

出力結果は:

tensor([True, True, False])

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

その他の拡張