设置默认tensor类型
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,示例错误?或者版本问题?
取得成绩的人无不拥有极强的自律精神和自我管理能力,认识世界必需自律,改造世界必须极度自律