torch - PyTorch : error message "torch has no [...] member"

标签 torch pytorch

晚上好,
我刚刚安装了 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/

相关文章:

neural-network - Caffe 中的空间反射填充

linux - Jupyter笔记本通过/etc/rc.local运行时找不到内核

performance - 使张量中的值符合给定范围

python - 在 Python 中安装 OpenFace 时遇到问题

python - pytorch损失如何与模型参数联系起来?

python - Pytorch 运行时错误 : size mismatch, m1 : [1 x 7744], m2:[400 x 120]

nginx - Openresty torch 模块加载问题

python - 如何让one-hot数据与非one-hot数据兼容?

mathematical-optimization - 如何在pytorch中手动应用渐变

python - Anaconda,更新Pytorch到最新版本1.5