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