python中torch.tensor 和 torch.Tensor的区别是什么
更新:HHH   时间:2023-1-7


这期内容当中小编将会给大家带来有关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的区别是什么了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注天达云行业资讯频道。

返回大数据教程...