前提
软件 | 版本 |
---|---|
python | 3.7.13 |
tensorflow | 2.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