torch.all()

torch.all() 其中的所有项都为True,返回True,反之,返回False

>>> import torch

>>> a = torch.tensor([[1, 2], [3, 4]])
>>> b = torch.tensor([[1, 2], [3, 4]])
>>> a
OUT: tensor([[1, 2],
             [3, 4]])
>>> torch.eq(a, b)
OUT:tensor([[True, True],
            [True, True]])
>>> torch.all(torch.eq(a, b))
OUT: tensor(True)
>>> torch.all(torch.tensor([True, False]))
OUT: tensor(False)

 

posted @ 2023-07-29 08:57  海_纳百川  阅读(334)  评论(0编辑  收藏  举报
本站总访问量