tensorflow2报错AttributeError: module ‘tensorflow._api.v2.train’ has no attribute ‘import_meta_graph’
代码
AttributeError: module 'tensorflow._api.v2.train' has no attribute 'import_meta_graph'
报错信息
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-7-e9798d5a8298> in <module>()
3 with old_alex_graph.as_default():
4 # importing the graph will populate new_alex_graph
----> 5 saver = tf.train.import_meta_graph("../week_06/saved_models/alexnet.meta")
AttributeError: module 'tensorflow._api.v2.train' has no attribute 'import_meta_graph'
解决方法
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()