例如:
import torch
a=torch.rand(3,4)
print(a.dtype)
可以得到类型:torch.float32
然后设置a的数据类型有两种方式:
a=a.float()--> torch.float32,
a=a.double()-->torch.float64
或者
a=torch.rand(3,2,dtype=torch.float32)
例如:
import torch
a=torch.rand(3,4)
print(a.dtype)
可以得到类型:torch.float32
然后设置a的数据类型有两种方式:
a=a.float()--> torch.float32,
a=a.double()-->torch.float64
或者
a=torch.rand(3,2,dtype=torch.float32)