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

这篇文章主要介绍“torch.eq和eq(other)怎么使用”,在日常操作中,相信很多人在torch.eq和eq(other)怎么使用问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”torch.eq和eq(other)怎么使用”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

函数功能说明:

逐元素比较两个张量是否相等,
这两个张量的形状必须是可以广播的.
返回的张量包含了各个位置上的布尔值,
代表了比较结果.

代码实验:

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.eq(input, other)tensor([[ True, False],[False,  True]])>>> torch.eq(input, other,)tensor([[ True, False],[False,  True]])>>>>>>>>>

到此,关于“torch.eq和eq(other)怎么使用”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注网站,小编会继续努力为大家带来更多实用的文章!