pytorch报错:AttributeError: module 'torch.nn._reduction' has no attribute 'get_enum'
-
本人小白,刚步入研究生生涯,看B站网课学机器学习,copy了视频里的代码在pycharm上跑了下报错了,各位大神能帮忙看看错误原因嘛 ,十分感谢!
代码链接:https://blog.csdn.net/bit452/article/details/109677086
报错原因:F:\Anaconda3\envs\pytorch\python.exe C:/Users/84462/PycharmProjects/pythonProject2/TEST.py
Traceback (most recent call last):
File "C:\Users\84462\PycharmProjects\pythonProject2\TEST.py", line 40, in <module>
loss = criterion(y_pred, y_data) # forward: loss
File "F:\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "F:\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\loss.py", line 530, in forward
return F.mse_loss(input, target, reduction=self.reduction)
File "F:\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\functional.py", line 3280, in mse_loss
return torch._C._nn.mse_loss(expanded_input, expanded_target, _Reduction.get_enum(reduction))
AttributeError: module 'torch.nn._reduction' has no attribute 'get_enum'