Summary of errors in running code in tensorflow environment

1. ImportError: No module named 'seaborn' (missing seaborn package)

solution:

(1) Enter your own environment and install the seaborn package

python -m pip install seaborn

(2) The command statement for updating Python is as follows:

python -m install pip --upgrade pip

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

solution:

将from keras.callbacks import EarlyStopping

Replace with:

from tensorflow.keras.callbacks import EarlyStopping


from tensorflow.keras.callbacks import EarlyStopping

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

solution:

Put from keras.optimizers import SGD

Replace with:

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

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

4. AttributeError: module 'tensorflow' has no attribute 'xxx' solution

solution:

(1) If the code you import the Tensorflow module is:

import tensorflow 
is replaced with:

import tensorflow.compat.v1


(2) If the code you import the Tensorflow module is:

import tensorflow as tf
is replaced by:

import tensorflow.compat.v1 as tf

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

solution:

Replace import tensorflow as tf
with: import tensorflow.compat.v1 as tf

Guess you like

Origin blog.csdn.net/weixin_61745097/article/details/130736301