在这里插入图片描述

Microsoft Windows [版本 10.0.18363.1256]
(c) 2019 Microsoft Corporation。保留所有权利。

C:\Users\chenxuqi>conda activate ssd4pytorch1_2_0

(ssd4pytorch1_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
>>>
>>>
Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐