torch.ge()函数解读
函数作用 torch.ge(a,b)比较a,b的大小,a为张量,b可以为和a相同形状的张量,也可以为一个常数。 代码示例 >>> import torch >>> a=torch.Tensor([[1,2,3],[4,5,6]]) >>> a tensor([[1., 2., 3.], [4., 5., 6.]]) >>> b=torch.Tensor([[2,2,2],[4,5,7]]) >>> b tensor([[2., 2., 2.], [4., 5., 7.]]) >>> torch.ge(a,b) #逐个元素比较 tensor([[0, 1, 1], [1, 1, 0]], dtype=torch.uint8) >>> c=torch.randn(4,4) >>> c tensor([[ 0.3021, 0.5238, -1.2107, 1.3706], [-0.0715, -0.1180, 0.2854, 0.2061], [ 0.7414, 0.2233, -0.4926, -0.6218], [-0.0471, 1.1931, 0.8465, -0.5087]]) >>> d=torch.randn(4,4) >>> d tensor([[-1.9698, 1.8576, 0.2773, 0.6412], [ 1.0153, 0.5828, 0.8718, -0