在vscode中,tensorflow.keras模块的下属模块无法自动补全,我在github官方respository的issue中找到了解决问题的方法,即进入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
标签:补全,keras,vscode,v2,api,._,import,tensorflow
From: https://www.cnblogs.com/kongaobo/p/16971333.html