问题:TypeError: nll_loss() got an unexpected keyword argument 'reduction'

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qian1996/article/details/84424303

got an unexpected keyword argument  多半是pytorch版本问题

查看源文件,没有reduction这个参数,但是官方文档里有。

import torch
print(torch.__version__) 

输出:0.4.0

卸载旧版本

pip3 install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp36-cp36m-win_amd64.whl

安装新版本 

pip uninstall torch

版本更新为0.4.1

成功运行

猜你喜欢

转载自blog.csdn.net/qian1996/article/details/84424303