在Tensor后加 .long(), .int(), .float(), .double()等即可,也可以用.to()函数进行转换,所有的Tensor类型可参考https://pytorch.org/docs/stable/tensors.html

import torch
a = torch.DoubleTensor((3, 2))

print(a.dtype)
a = a.float()

print(a.dtype)

torch.float64
torch.float32

相关文章:

  • 2022-12-23
  • 2021-07-08
  • 2022-12-23
  • 2021-11-12
  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2021-04-28
  • 2022-12-23
  • 2021-10-21
  • 2022-12-23
相关资源
相似解决方案