Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What is the difference between torch.tensor and torch.Tensor in python

Shulou Source: shulou.com Published: 2022-06-02 07:13:16 10月02日 Update

In this issue, the editor will bring you about the difference between torch.tensor and torch.Tensor in python. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

Microsoft Windows [version 10.0.18363.1256] (c) 2019 Microsoft Corporation. All rights reserved. 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 > > a = torch.Tensor (2) > > atensor ([3.1820e-24) 4.5909e-41]) > > a.type () 'torch.FloatTensor' > a.dtypetorch.float32 > a = torch.tensor (2) > > atensor (2) > a.type ()' torch.LongTensor' > a.dtype () Traceback (most recent call last): File ", line 1, in TypeError: 'torch.dtype' object is not callable > > a.type > a.dtypetorch.int64 > a = torch.Tensor ([1, 2]) > > atensor ([1, 2]) > > print (a) tensor ([1. 2.]) > a.type () 'torch.FloatTensor' > a.dtypetorch.float32 > a = torch.tensor ([1Mague 2]) > print (a) tensor ([1Yue2]) > a.type ()' torch.LongTensor' > a.dtypetorch.int64 > a = torch.tensor ([1.Person2.]) > atensor ([1.Lie2.]) > print (a) tensor ([1. 2.]) > a.type () 'torch.FloatTensor' > a.dtypetorch.float32 > above is the difference between torch.tensor and torch.Tensor in python shared by the editor. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Tags: Content analysis professional small and medium rich in content that is articles more rights versions knowledge articles industries perspectives information information channels channels related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB OPPO Reno Shulou Information Redmi NVidia