pytorch 中的张量如何修改数据类型

tensor张量有不同的数据类型,例如torch.long,torch.float32,torch.float16等之间可以相互转化

import torch
x  = torch.zeros([2,2])
x = x.to(torch.long)
x = x.to (torch.float32)

猜你喜欢

转载自blog.csdn.net/weixin_37707670/article/details/120853210