tensorflow的新老api异常

前提

软件版本
python3.7.13
tensorflow2.3.0

这是个人在学习tensorflow过程中所收集的一些新老api的不同用处,来源则是csdn等所有博客网站等以及个人提供的解决方案。我会贴出所有出处。
如果新旧api的返回类型或者是其他有所不同,请看官方文档。

0、版本推荐

版本这里我没有取验证。我单纯地给方法换成旧的api

https://www.likecs.com/ask-123102.html
https://stackoverflow.com/questions/70361319/attributeerror-module-tensorflow-keras-layers-has-no-attribute-rescaling
https://blog.csdn.net/weixin_41194171/article/details/118145087

1、module ‘tensorflow._api.v2.data‘ has no attribute ‘AUTOTUNE

来源:

https://blog.csdn.net/weixin_41938996/article/details/115285790?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-115285790-blog-118145087.pc_relevant_multi_platform_featuressortv2removedup&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-115285790-blog-118145087.pc_relevant_multi_platform_featuressortv2removedup

AUTOTUNE = tf.data.AUTOTUNE
#更换为
AUTOTUNE = tf.data.experimental.AUTOTUNE

2、AttributeError: module ‘tensorflow.keras.layers’ has no attribute ‘Rescaling’

https://blog.csdn.net/Crystal_remember/article/details/116830963

  layers.experimental.preprocessing.Resizing(IMG_SIZE, IMG_SIZE), 
  layers.experimental.preprocessing.Rescaling(1./255),
# 个人补充,对图片处理基本上都在这个文件,
 layers.experimental.preprocessing.RandomRotation(0.1),
 layers.experimental.preprocessing.RandomZoom(0.1),
 layers.experimental.preprocessing.RandomFlip()

3、module ‘tensorflow.keras.utils’ has no attribute ‘load_img’

http://www.manongjc.com/detail/31-kjhjzcwqcucukdj.html

tf.keras.utils.load_img()
tf.keras.utils.img_to_array()
# 换成
tf.keras.preprocessing.image.load_img()
tf.keras.preprocessing.image.img_to_array()

4、module ‘tensorflow._api.v2.image’ has no attribute ‘stateless_random_brightness’

解决:这个没有找到,需要更新到2.5以上

下面的链接是安装教程,非常好,起码在镜像上的使用非常到位

https://blog.csdn.net/qq_37374643/article/details/90597365

  • 7
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

徐子元竟然被占了!!

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值