from keras.layers.normalization.batch_normalization_v1 import BatchNormalization
No module named ‘keras.backend.tensorflow_backend’; ‘keras.backend’ is not a package
错误 报错 No module named ‘keras.backend.tensorflow_backend’; ‘keras.backend’ is not a package
解决 from keras.backend.tensorflow_backend import set_session替换为 from keras.backend import set_session
from keras.backend import set_session
module ‘tensorflow’ has no attribute ‘ConfigProto’
错误 报错 module ‘tensorflow’ has no attribute ‘ConfigProto’
解决 使用Tensorflow 2.0会出现AttributeError: module ‘tensorflow’ has no attribute 'ConfigProto’这个问题,这个是由于现在新版本中一些1.0版本的函数被和2.0版本函数区分开的缘故,需要将tf.ConfigProto修改为tf.compat.v1.ConfigProto
Unable to open file (truncated file: eof = 18044416, sblock->base_addr = 0, stored_eof = 574710816)
错误 报错 Unable to open file (truncated file: eof = 18044416, sblock->base_addr = 0, stored_eof = 574710816)
AttributeError: module ‘tensorflow’ has no attribute 'config’
错误 报错 AttributeError: module ‘tensorflow’ has no attribute ‘config’
解决 config 替换为ConfigProto(tensorflow1.0改2.0代码)
FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.
错误 报错 FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.
解决 安装低版本的Numpy即可 pip install numpy==1.16.0
google.protobuf.pyext._message.FieldProperty’ object has no attribute 'list_physical_devices
错误 报错 google.protobuf.pyext._message.FieldProperty’ object has no attribute 'list_physical_devices
解决 直接干掉了相关代码,用cpu跑,跑起来了再说,然后就被教育了,cpu太慢了
expected predictions to have shape (5,) but got array with shape (3,)
错误 报错 google.protobuf.pyext._message.FieldProperty’ object has no attribute 'list_physical_devices
解决 Dense输出类别错误 x = Dense(3, activation=‘softmax’, name=‘predictions’)(x) # 输出类别
** 5 out of the last 5 calls to <function Model.make_predict_function..predict_function at 0x00000000178B3798> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/guide/function#controlling_retracing and https://www.tensorflow.org/api_docs/python/tf/function for more details. **
错误 官方原因: This warning occurs when a TF function is retraced because its arguments change in shape or dtype (for Tensors) or even in value (Python or np objects or variables). 当一个 TF 函数被回溯时会出现这个警告,因为它的参数在形状或 dtype(对于张量)甚至值(Python 或 np 对象或变量)上发生了变化. 解决方案是1.循环中使用,2使用不重复的参数,3使用宽松灵活的参数,对这个地方理解不是很明白,但是用下面的代码确实可以解决这个警告。
解决 model.predict(image)改成model(X_test)
’NoneType’ object has no attribute 'reshape’
错误 在图像分类前期进行图像处理时报错,原因是文件中有中文路径,看了一下果然有一个文件为中文名称
解决 修改中文名称
OSError: SavedModel file does not exist at: ./model/.hdf5{saved_model.pbtxt|saved_model.pb}
cannot import name ‘BatchNormalization’ from 'keras.layers.normalization’错误拉取一份代码,报错cannot import name ‘BatchNormalization’ from ‘keras.layers.normalization’解决将原导入from keras.layers.normalization import BatchNormalization修改为from keras.layers.normaliza