捷徑

torch.lcm

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

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

inputother 必須都具有整數類型。

注意

這定義了 lcm(0,0)=0lcm(0, 0) = 0 以及 lcm(0,a)=0lcm(0, a) = 0

參數
  • input (Tensor) – 輸入張量。

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

關鍵字參數

out (Tensor, optional) – 輸出張量 (可選)。

範例

>>> 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 的完整開發者文件

檢視文件

教學

取得初學者和進階開發者的深入教學

檢視教學

資源

尋找開發資源並取得問題解答

檢視資源