安装好 torch-1.1.0-cp36-cp36m-win_amd64.whl后提示torch.nn.TransformerEncoderLayer 不能用

问题:

     安装好  torch-1.1.0-cp36-cp36m-win_amd64.whl后提示torch.nn.TransformerEncoderLayer 不能用

     提示错误为:'torch.nn' has no attribute 'TransformerEncoderLayer'

解决方法: 

     安装Torch包1.2 进行解决

解决方案来源:

1.PyTorch中Transformer模型的使用 

https://www.jianshu.com/p/23b527e0f696

2.Pytorch1.2 cpu版本安装教程(附加GPU下载)

 安装好 torch-1.1.0-cp36-cp36m-win_amd64.whl后提示torch.nn.TransformerEncoderLayer 不能用

https://blog.****.net/qq_41375318/article/details/102483339

3.使用Pip安装时速度慢或是下载不下来时直接在官网下载到本地进行安装

https://download.pytorch.org/whl/torch_stable.html 页面如下

安装好 torch-1.1.0-cp36-cp36m-win_amd64.whl后提示torch.nn.TransformerEncoderLayer 不能用

4. 安装:

pip install 下载的文件路径名称