AttributeError: module ‘keras.backend‘ has no attribute ‘set_session‘
·
AttributeError: module ‘keras.backend’ has no attribute ‘set_session’
出现这个错误主要是因为tensorflow2.0以上的版本已经没有set_session了,所有需改一下:
from keras import backend as K
tf_session = tf.compat.v1.Session(graph=tf.compat.v1.get_default_graph(),config=config)
K.set_session(tf_session)
报错:
AttributeError: module 'keras.backend' has no attribute 'set_session'
修改为:
tf_session = tf.compat.v1.Session(graph=tf.compat.v1.get_default_graph(),config=config)
tf.compat.v1.keras.backend.set_session(tf_session)
运行成功!
更多推荐



所有评论(0)