PyTorch torch.lcm 関数
torch.lcmPyTorch で2つのテンソル要素間の最小公倍数(Least Common Multiple)を計算するための関数です。
関数定義
torch.lcm(input, other, out=None)
パラメータの説明:
input: 最初の入力テンソルother: 2番目の入力テンソルout: 出力テンソル
使用例
例
import torch
# 2つのテンソルを作成
a = torch.tensor([3, 4, 5])
b = torch.tensor([6, 8, 10])
# 最小公倍数を計算
y = torch.lcm(a, b)
print(y)
# 2つのテンソルを作成
a = torch.tensor([3, 4, 5])
b = torch.tensor([6, 8, 10])
# 最小公倍数を計算
y = torch.lcm(a, b)
print(y)
出力結果は:
tensor([ 6, 8, 10])
例
import torch
# 2つのテンソルを作成
a = torch.tensor([12, 15])
b = torch.tensor([18, 25])
# 最小公倍数を計算
y = torch.lcm(a, b)
print(y)
# 2つのテンソルを作成
a = torch.tensor([12, 15])
b = torch.tensor([18, 25])
# 最小公倍数を計算
y = torch.lcm(a, b)
print(y)
出力結果は:
tensor([ 36, 75])
その他の拡張
Pytorch torch リファレンスマニュアル