这期内容当中小编将会给大家带来有关python中torch.tensor 和 torch.Tensor的区别是什么,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
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>>> a = torch.Tensor(2)>>> a
tensor([3.1820e-24, 4.5909e-41])>>> a.type()'torch.FloatTensor'>>> a.dtype
torch.float32>>>>>> a = torch.tensor(2)>>> a
tensor(2)>>> a.type()'torch.LongTensor'>>> a.dtype()Traceback (most recent call last):
File "<stdin>", line 1, in <module>TypeError: 'torch.dtype' object is not callable>>> a.type<built-in method type of Tensor object at 0x00000202FAE8AEF8>>>> a.dtype
torch.int64>>>>>>>>> a = torch.Tensor([1,2])>>> a
tensor([1., 2.])>>> print(a)tensor([1., 2.])>>> a.type()'torch.FloatTensor'>>> a.dtype
torch.float32>>>>>>>>>>>>>>> a = torch.tensor([1,2])>>> print(a)tensor([1, 2])>>> a.type()'torch.LongTensor'>>> a.dtype
torch.int64>>>>>>>>> a = torch.tensor([1.,2.])>>> a
tensor([1., 2.])>>> print(a)tensor([1., 2.])>>> a.type()'torch.FloatTensor'>>> a.dtype
torch.float32>>>>>>
上述就是小编为大家分享的python中torch.tensor 和 torch.Tensor的区别是什么了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注亿速云行业资讯频道。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。
原文链接:https://my.oschina.net/u/4851203/blog/4825567