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,示例錯誤?或者版本問題?