當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python PyTorch lcm用法及代碼示例

本文簡要介紹python語言中 torch.lcm 的用法。

用法:

torch.lcm(input, other, *, out=None) → Tensor

參數

  • input(Tensor) -輸入張量。

  • other(Tensor) -第二個輸入張量

關鍵字參數

out(Tensor,可選的) -輸出張量。

計算 inputother 的元素最小公倍數 (LCM)。

inputother 都必須具有整數類型。

注意

這定義了

例子:

>>> a = torch.tensor([5, 10, 15])
>>> b = torch.tensor([3, 4, 5])
>>> torch.lcm(a, b)
tensor([15, 20, 15])
>>> c = torch.tensor([3])
>>> torch.lcm(a, c)
tensor([15, 30, 15])

相關用法


注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torch.lcm。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。