捷徑

torch.equal

torch.equal(input, other) bool

如果兩個張量具有相同的大小和元素,則為 True,否則為 False

請注意,包含 NaN 的張量永遠不會彼此相等。

範例

>>> torch.equal(torch.tensor([1, 2]), torch.tensor([1, 2]))
True
>>> torch.equal(torch.tensor([3, torch.nan]), torch.tensor([3, torch.nan]))
False

文件

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources