简体   繁体   中英

tensorflow error: module has no attribute GraphDef

i am following this tutorial here and I am running into an error 20 minutes after I run the code. Here is the code and the error.

the code is here code

error:

od_graph_def = tf.GraphDef()
AttributeError: module 'tensorflow' has no attribute 'GraphDef'

You may be using tensorflow 2.0. If that is the case, to use TF-1 within TF-2, the import statement should be edited as below.

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

AttributeError: module 'tensorflow' has no attribute 'GraphDef'/ 'Session'

Since the version of tf2 is under Ubuntu, it will be different from the previous version.

change tf.GraphDef() -> tf.compat.v1.GraphDef()

change tf.Session() -> tf.compat.v1.Session()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM