tensorflow环境下运行代码出现的错误汇总

1. ImportError: No module named ‘seaborn‘(缺少seaborn包)

解决方案:

(1)进入自己环境,安装seaborn包的安装

python -m pip install seaborn

(2)更新Python的命令语句如下:

python -m install pip --upgrade pip

2.AttributeError: 'EarlyStopping' object has no attribute '_implements_train_batch_hooks'

解决方案:

将from keras.callbacks import EarlyStopping

替换为:

from tensorflow.keras.callbacks import EarlyStopping


from tensorflow.keras.callbacks import EarlyStopping

3.importError: cannot import name ‘SGD‘ from ‘keras.optimizers‘

解决方案:

把from keras.optimizers import SGD

替换为:

from tensorflow.keras.optimizers import Adam,Nadam, SGD

from tensorflow.keras.optimizers import Adam,Nadam, SGD

4.AttributeError: module ‘tensorflow’ has no attribute ‘xxx’ 解决办法

解决方案:

(1)如果你导入Tensorflow模块的代码为:

import tensorflow 
替换为:

import tensorflow.compat.v1


(2)如果你导入Tensorflow模块的代码为:

import tensorflow as tf
则替换为:

import tensorflow.compat.v1 as tf

5.AttributeError: module 'tensorflow' has no attribute 'GPUOptions'

解决方案:

将 import tensorflow as tf
替换为:import tensorflow.compat.v1 as tf

你可能感兴趣的:(python,开发语言)