torch.nn没有名为upsample

时间:2017-12-04 14:46:51

标签: python pytorch

遵循本教程:https://www.digitalocean.com/community/tutorials/how-to-perform-neural-style-transfer-with-python-3-and-pytorch#step-2-%E2%80%94-running-your-first-style-transfer-experiment

当我在Jupyter笔记本中运行示例时,我得到以下内容:

enter image description here

所以,我已经尝试过排查,最终让我按照github示例(https://github.com/zhanghang1989/PyTorch-Multi-Style-Transfer)运行它来通过命令行说:

python main.py eval --content-image images/content/venice-boat.jpg --style-image images/21styles/candy.jpg --model models/21styles.model --content-size 1024 --cuda=0

但是,这会出现以下错误:

Traceback (most recent call last):
File "main.py", line 287, in <module>
main()
File "main.py", line 44, in main
evaluate(args)
File "main.py", line 242, in evaluate
stylemodel = Net(ngf=args.ngf)
File "/root/styletransfer/PyTorch-Style-Transfer/experiments/net.py", line 284, in init
model += [upblock(ngf*expansion, 32, 2, normlayer),
File "/root/styletransfer/PyTorch-Style-Transfer/experiments/net.py", line 127, in init
kernelsize=1, stride=1, upsample=stride)
File "/root/styletransfer/PyTorch-Style-Transfer/experiments/net.py", line 167, in init
self.upsamplelayer = torch.nn.Upsample(scalefactor=upsample)
AttributeError: module 'torch.nn' has no attribute 'Upsample'

我无法弄清楚如何克服这个过程?

1 个答案:

答案 0 :(得分:2)

我认为原因可能是您的系统上有旧版PyTorch。在我的系统上,pytorch版本是0.2.0,torch.nn有一个名为Upsample的模块。

您可以卸载当前版本的pytorch和reinstall it