Ubuntu 16.04.2 LTS
Nvidia GeForce RTX 3080*2 CUDA Version 11.2
tensorflow 2.5.0
keras 2.7.0
报错信息:训练时报错如下:
AttributeError: module 'tensorflow.compat.v2.__internal__' has no attribute 'register_clear_session_function'解决方法:
之前python脚本头:
from keras.models import Model from keras.layers import Input, Conv2D, GlobalAveragePooling2D, Dropout from keras.layers import Activation, BatchNormalization, Add, Reshape, DepthwiseConv2D from keras.utils.vis_utils import plot_model from keras.optimizers import Adam from keras.preprocessing.image import ImageDataGenerator from keras.callbacks import EarlyStopping from keras import backend as K
修改为如下即可:
from tensorflow.python.keras.models import Model from tensorflow.python.keras.layers import Input, Conv2D, GlobalAveragePooling2D, Dropout from tensorflow.python.keras.layers import Activation, BatchNormalization, Add, Reshape, DepthwiseConv2D from tensorflow.python.keras.utils.vis_utils import plot_model from tensorflow.keras.optimizers import Adam from tensorflow.python.keras.preprocessing.image import ImageDataGenerator from tensorflow.python.keras.callbacks import EarlyStopping from tensorflow.python.keras import backend as K根本原因:
tensorflow-gpu 1.12(tf一代keras)的代码在tensorflow2.x(tf2二代keras)使用时,keras模块调用路径变更了而已。诸如此类问题还有一大推。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)