Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use torch.eq and eq (other)

Shulou Source: shulou.com Published: 2022-06-01 08:12:58 10月02日 Update

This article mainly introduces "how to use torch.eq and eq (other)". In daily operation, I believe many people have doubts about how to use torch.eq and eq (other). The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "how to use torch.eq and eq (other)". Next, please follow the editor to study!

Function description:

Element by element to compare whether two tensors are equal, the shape of the two tensors must be broadcast. The returned tensor contains Boolean values at each location, representing the result of the comparison.

Code experiment:

C:\ Users\ chenxuqi > conda activate ssd4pytorch2_2_0 (ssd4pytorch2_2_0) C:\ Users\ chenxuqi > pythonPython 3.7.7 (default, May 6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)]:: Anaconda, Inc. On win32Type "help", "copyright", "credits" or "license" for more information. > import torch > > input = torch.tensor ([[1,2], [3,4]]) > > other = torch.tensor ([[1,1], [4]) ) > inputtensor ([1,2], [3,4]]) > othertensor ([1,1], [4,4]]) > torch.eq (input, other) tensor ([[True, False], [False, True]]) > torch.eq (input, other,) tensor ([True, False], [False, True]]) > so far The study on "how to use torch.eq and eq (other)" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Learning tensor two more help practical next code representation position element function function Boolean shape article method theory knowledge article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Shulou Technology Microsoft Linux Xiaomi