torch.le和le(other)怎么使用

本篇内容主要讲解“torch.le和le(other)怎么使用”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“torch.le和le(other)怎么使用”吧!

函数使用说明:

两个可广播的张量之间的逐元素比较操作,
判断每个位置上的元素是否满足小于等于.

代码实验举例:

Microsoft Windows [版本 10.0.18363.1256](c) 2019 Microsoft Corporation。保留所有权利。

C:\Users\chenxuqi>conda activate ssd4pytorch2_2_0(ssd4pytorch2_2_0) C:\Users\chenxuqi>python
Python 3.7.7 (default, May  6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.>>> import torch>>> input = torch.tensor([[1, 2], [3, 4]])>>> other = torch.tensor([[1, 1], [4, 4]])>>> inputtensor([[1, 2],[3, 4]])>>> other
tensor([[1, 1],[4, 4]])>>> torch.le(input, other)tensor([[ True, False],[ True,  True]])>>>>>>>>>

到此,相信大家对“torch.le和le(other)怎么使用”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!