PyTorch : error message “torch has no […] member”

In case you haven’t got a solution to your problem or someone else encounters it.

The error is raised because of Pylint (Python static code analysis tool) not recognizing rand as the member function. You can either configure Pylint to ignore this problem or you can whitelist torch (better solution) to remove lint errors by adding following to your .pylintrc file.

[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.*

In Visual Studio Code, you could also add the following to the user settings:

"python.linting.pylintArgs": [
"--generated-members=numpy.* ,torch.*"
]

The issue is discussed here on PyTorch GitHub page.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)