I try to use expit(x) from SciPy. But I get this error message:
Module 'scipy.special' has no 'expit' member
This is my code:
import numpy
import scipy.special
[...]
def Activation(self, ActivationInput):
self.ActivationOutput = scipy.special.expit(ActivationInput)
return self.ActivationOutput
scipy
is red underlined in VScode when I try to us it in the function Activation
The solution via Error importing scipy.special.expit was not satisfying and doesn't work.
I use Python 3.7, NumPy 1.14.5 and SciPy 1.1.0.
Other functions work, but all Ufuncs from scipy.special
get this error message.
All of the ufuncs in scipy.special
are written in C and so pylint cannot find the proper definition. You can tell pylint to ignore the module by adding the option --ignored-modules=scipy.special
to pylint.
Adding --ignored-modules=scipy.special
via the options GUI or directly to the settings.JSON file is possible, but it turns off the default options that VSCode uses with pylint.
To solve this issue, you can add both the original default options as well as the --ignored-modules
flag to the settings.json file.
[CTRL]+[Shift]+p
to open the command searchopen settings (JSON)
, which will open you settings file.settings.JSON
add the key / value pairs so you file has the following{
// any other options for VSCode
"python.linting.pylintArgs": [
"--disable=all",
"--enable=F,E,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned",
"--enable=unused-variable,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode",
"--ignored-modules=scipy.special"
],
}
The first 3 lines are the default options used by VSCode for pylint. The 4th line tells pylint to ignore the scipy.special
module, which will turn off the error.
It looks like this could be a Pylint issue like this one . Did you try if you can execute your code?
As a workaround you could try and disable the no-member/E1101 rule:
#pylint: disable=no-member
self.ActivationOutput = scipy.special.expit(ActivationInput)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.