AttributeError: module ‘tensorflow.keras.preprocessing’ has no attribute ‘image_dataset_from_directory’
使用tensorflow官网的图片分类实例教程发现上述问题
tf官网图片分类例子链接
问题解决方案:将tensorflow由2.1.0升级至2.3.0即可
最好先卸载自己的低版本tensorflow,再重新安装, 我试过使用
pip install upgrade 的方法,但是会出现依赖不匹配问题
直接升级参考下面的文章,但是不太管用,至少我是这样
pip install --upgrade参考方法链接
解决问题的方法来源:
解决方法参考链接
上述两种方法我都试过,安装tf-nightly的话出现了一个问题,就是我的环境中存在maplotlib的包,但是在程序运行时会出现问题,目前还没有解决,因为方法2直接就可以用了,所以暂时搁置,我发觉自己有点懒,哈哈哈
方法1出现如下问题
RuntimeError: The current Numpy installation ('C:\\Users\\diyue\\Anaconda3\\envs\\tf2-nightly-gpu\\lib\\site-packages\\numpy\\__init__.py') fails to pass a sanity check due to a bug in the windows runtime. See this issue for more information: https://tinyurl.com/y3dm3h86
方法2直接可以使用