PyTorch torch.less 関数


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

torch.lessは、PyTorch で要素ごとに小なり比較を行うための関数です。最初のテンソルの要素が 2 番目のテンソルの対応する要素より小さい位置に True を持つテンソルを返します。

関数定義

torch.less(input, other)

使用例

実例

import torch

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

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

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

tensor([False, False, False])

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

その他の拡張