惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 三生石上(FineUI控件)
V
Vulnerabilities – Threatpost
C
Cisco Blogs
A
Arctic Wolf
L
LINUX DO - 热门话题
P
Proofpoint News Feed
Security Latest
Security Latest
AWS News Blog
AWS News Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Cisco Talos Blog
Cisco Talos Blog
L
Lohrmann on Cybersecurity
W
WeLiveSecurity
爱范儿
爱范儿
Last Week in AI
Last Week in AI
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Security Affairs
PCI Perspectives
PCI Perspectives
C
Cybersecurity and Infrastructure Security Agency CISA
Spread Privacy
Spread Privacy
IT之家
IT之家
月光博客
月光博客
云风的 BLOG
云风的 BLOG
宝玉的分享
宝玉的分享
J
Java Code Geeks
美团技术团队
酷 壳 – CoolShell
酷 壳 – CoolShell
I
Intezer
博客园_首页
博客园 - 司徒正美
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Palo Alto Networks Blog
NISL@THU
NISL@THU
Recent Commits to openclaw:main
Recent Commits to openclaw:main
有赞技术团队
有赞技术团队
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
量子位
The Last Watchdog
The Last Watchdog
Google Online Security Blog
Google Online Security Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 聂微东
N
News and Events Feed by Topic
Webroot Blog
Webroot Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
Security @ Cisco Blogs
罗磊的独立博客
大猫的无限游戏
大猫的无限游戏
The Cloudflare Blog
V
V2EX
Jina AI
Jina AI

博客园 - cpuimage

AIGC图像困局 深度学习优化器算法巧思速览 lora训练之偷师 大话AI绘画技术原理与算法优化 Tensorflow2 深度学习十必知 开源发丝分割数据集CelebAHairMask-HQ(国庆献礼) 博文大纲 文字渲染一探 磨皮美颜算法 附完整C代码 Windows下C,C++开发环境搭建指南 一种简单高效的音频降噪算法示例(附完整C代码) 算法踩坑小记 音频算法之我思 wav2midi 音乐旋律提取算法 附可执行demo 图像去模糊算法 循序渐进 附完整代码 音频算法之小黄人变声 附完整C代码 音频识别算法思考与阶段性小结 大话音频变声原理 附简单示例代码 c语言智能指针 附完整示例代码
自 TensorFlow 2.6 起,修正IDE代码自动补全失效的方法
cpuimage · 2022-02-06 · via 博客园 - cpuimage

很久没写博文,写这个,只是纯粹为了吐槽tf越升级,问题越多。

自TensorFlow 2.6 至 TensorFlow 2.9.1

各个IDE工具的tf.keras 自动补全失效了。

修正办法:

修改python的tensorflow包初始化文件:

site-packages\tensorflow\_init_.py

将其中的代码:

_keras_module = "keras.api._v2.keras"
keras = _LazyLoader("keras", globals(), _keras_module)
_module_dir = _module_util.get_parent_dir_for_name(_keras_module)
if _module_dir:
  _current_module.__path__ = [_module_dir] + _current_module.__path__
setattr(_current_module, "keras", keras)

改为:

import typing as _typing 
if _typing.TYPE_CHECKING: 
  from keras.api._v2 import keras
else:
  _keras_module = "keras.api._v2.keras"
  keras = _LazyLoader("keras", globals(), _keras_module)
  _module_dir = _module_util.get_parent_dir_for_name(_keras_module)
  if _module_dir:
    _current_module.__path__ = [_module_dir] + _current_module.__path__
  setattr(_current_module, "keras", keras)

重启IDE即可。

相关issues见链接:

https://github.com/tensorflow/tensorflow/issues/53144#issuecomment-985179600

看到很多人都转投pytorch了,博主还在坚守tensorflow阵地。

怒其不争,TensorFlow团队能少搞点幺蛾子不~