torch.eq¶ torch.eq(input, other, *, out=None) → Tensor¶ 逐元素地計算相等性。 第二個參數可以是一個數字或是一個張量,其形狀與第一個參數是 可廣播的。 參數 input (Tensor) – 要比較的張量 other (Tensor 或 float) – 要比較的張量或值 關鍵字參數 out (Tensor, optional) – 輸出張量。 返回值 一個布林張量,當 input 等於 other 時為 True,否則為 False 範例 >>> torch.eq(torch.tensor([[1, 2], [3, 4]]), torch.tensor([[1, 1], [4, 4]])) tensor([[ True, False], [False, True]])