How to use the torch.equal function
This article introduces the knowledge of "how to use the torch.equal function". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Code experiment:
(base) PS C:\ Users\ chenxuqi > pythonPython 3.7.4 (default, Aug 9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)]:: Anaconda, Inc. On win32Type "help", "copyright", "credits" or "license" for more information. > > import torch > > torch.equal (torch.tensor ([1,2]), torch.tensor ([1,2]) True > > torch.equal (torch.tensor ([1,2])), torch.tensor ([[1]) [2]]) False > > torch.equal (torch.tensor ([[1,2]]), torch.tensor ([[1], [2])) False > torch.equal (torch.tensor ([1,2]), torch.tensor ([1,2.0]) Traceback (most recent call last): File ", line 1, in RuntimeError: Expected object of scalar type Long but got scalar type Float for argument # 2 'other' > torch.equal (torch.tensor ([1,2]), torch.tensor ([1.0]) ) Traceback (most recent call last): File ", line 1, in RuntimeError: Expected object of scalar type Long but got scalar type Float for argument # 2 'other' > torch.equal (torch.tensor ([1.0,2.0]), torch.tensor ([1.0,2.0])) True >" how to use the torch.equal function "ends here Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!