python版本:Python 3.8.2

pytorch版本:1.5.0+cpu

import torch

torch.set_default_tensor_type('torch.IntTensor')   # tensor 类型设置默认类型语句:输入为字符:'  '

报错:

Traceback (most recent call last):
File "<input>", line 1, in <module>
File "D:\Python\lib\site-packages\torch\__init__.py", line 206, in set_default_tensor_type
_C._set_default_tensor_type(t)
TypeError: only floating-point types are supported as the default type

(仅支持浮点数作为默认类型)

改为:

torch.set_default_tensor_type('torch.DoubleTensor') 

torch.set_default_tensor_type('torch.FloatTensor') 

无报错

 

《深度学习框架Pytorch入门与实践》  P63,示例错误?或者版本问题?

相关文章:

  • 2021-05-15
  • 2021-11-25
  • 2021-08-23
  • 2021-07-30
  • 2021-11-26
  • 2021-10-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-04-25
  • 2022-12-23
  • 2022-12-23
  • 2021-11-09
  • 2021-07-08
  • 2021-12-10
  • 2022-12-23
相关资源
相似解决方案