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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 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团队能少搞点幺蛾子不~