晚上好,
我刚刚安装了 PyTorch 0.4.0,我正在尝试执行第一个教程“什么是 PyTorch?”
我编写了一个 Tutorial.py 文件,我尝试使用 Visual Studio Code 执行该文件
这是代码:
from __future__ import print_function
import torch
print (torch.__version__)
x = x = torch.rand(5, 3)
print(x)
不幸的是,当我尝试调试它时,我收到一条错误消息:
“火炬没有兰特成员”
这适用于我可以尝试的任何火炬成员函数
有人可以帮我吗?
最佳答案
如果您的问题没有解决方案或其他人遇到它。
由于 Pylint(Python 静态代码分析工具)无法识别 rand
而引发的错误作为成员函数。您可以将 Pylint 配置为忽略此问题,也可以通过将以下内容添加到您的 .pylintrc
来将 Torch(更好的解决方案)列入白名单以消除 lint 错误。文件。
[TYPECHECK]
# List of members which are set dynamically and missed by Pylint inference
# system, and so shouldn't trigger E1101 when accessed.
generated-members=numpy.*, torch.*
在 Visual Studio Code 中,您还可以将以下内容添加到用户设置中:
"python.linting.pylintArgs": [
"--generated-members=numpy.* ,torch.*"
]
问题讨论 here在 PyTorch GitHub 页面上。
关于torch - PyTorch : error message "torch has no [...] member",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50319943/