AttributeError: module ‘tensorflow‘ has no attribute ‘GraphDef‘ 或者‘Session‘
·
在tensorflow2运行代码出现此问题。
module ‘tensorflow’ has no attribute 'XXX’一般是tensorflow2和tensorflow1 不兼容问题。
问题解决办法:在tf后面加.compat.v1
事例1(module ‘tensorflow’ has no attribute ‘GraphDef’):
tensorflow1下:
tf.GraphDef()
tensorflow2下:
tf.compat.v1.GraphDef()
事例2(module ‘tensorflow’ has no attribute ‘Session’):
tensorflow1下:
tf.Session(graph=detection_graph)
tensorflow2下:
tf.compat.v1.Session(graph=detection_graph)
更多推荐
所有评论(0)