在更新tf2.x之后往往会出现以下问题
AttributeError: module ‘tensorflow’ has no attribute ‘ConfigProto’
AttributeError: module ‘tensorflow’ has no attribute ‘Session’
这是因为版本问题,需要进行修改
只需要将
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config)
改为即可
config = tf.compat.v1.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.compat.v1.Session(config=config)