Reputation: 351
The VSCode autocomplete option doesn't work for tensorflow and keras libraries; However i've installed python and pylance extension on it; is there any solution to make it work or not, without install new extension or something like as AI autocomplete; Kite and tabinine?
For instance, here i'm trying to use layers or preprocessing from keras API but it doesn't show anything at all
Also notice here the tensorflow version and python version
Upvotes: 3
Views: 3252
Reputation: 9727
try adding this to the bottom of your
tensorflow/__init__.py
# Explicitly import lazy-loaded modules to support autocompletion. # pylint: disable=g-import-not-at-top if _typing.TYPE_CHECKING: from tensorflow_estimator.python.estimator.api._v2 import estimator as estimator from keras.api._v2 import keras from keras.api._v2.keras import losses from keras.api._v2.keras import metrics from keras.api._v2.keras import optimizers from keras.api._v2.keras import initializers # pylint: enable=g-import-not-at-top
Find the location of the tensorflow
package and open the __init__.py
file in the tensorflow
folder
Add the above codes at the bottom of the file
It should be noted that it will be useful to import in the following way
import tensorflow as tf
tf.keras
Importing in the previous way still can't get intellisense
Upvotes: 5