Solve the module 'tensorflow' has no attribute '...' series


The error reporting problems encountered during the tensflow debugging process have been sorted out, which may not be complete. Refer to other blog posts for successful solutions.
It's all due to the difference in the version of tensflow.

解决module ‘tensorflow’ has no attribute ‘reset_default_graph’

Original code:

import tensorflow as tf
tf.reset_default_graph()

change to:

import tensorflow as tf
tf.compat.v1.reset_default_graph()

解决module ‘tensorflow’ has no attribute ‘Session’

Original code:

import tensorflow as tf
with tf.Session(graph=detection_graph) as sess:

change to:

import tensorflow as tf
with tf.compat.v1.Session(graph=detection_graph) as sess:

解决module ‘tensorflow’ has no attribute ‘GraphDef’

od_graph_def = tf.compat.v1.GraphDef()
Original code:

import tensorflow as tf
od_graph_def = tf.GraphDef()

change to:

import tensorflow as tf
od_graph_def = tf.compat.v1.GraphDef()

Guess you like

Origin blog.csdn.net/qq_45699150/article/details/120958872