PyTorch数据类型 Tensor
类型查看
a=torch.randn(2,3)
- a.type()
- type(a)
- isinstance(a,torch.FloatTensor)
cuda 类型
- isinstance(data,torch.cuda.DoubleTensor)
是False - data=data.cuda()
- isinstance(data,torch.cuda.DoubleTensor)
是True
标量 (dim 0)
- a= torch.tenscor(1.)
返回一个tensor(1.) - a.shape
返回一个torch.Size([ ]) - a.size()
返回 torch.Size([ ]) - len(a.shape)
返回 0 - a.dim()
返回 0
0维tensor