Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tensor.graph is meaningless when eager execution is enabled

a = tf.compat.v1.constant(5.0)
b = tf.compat.v1.constant(6.0)

sum1 = a + b
g = tf.compat.v1.Graph()
with g.as_default():
    # Define operations and tensors in `g`.
    hello = tf.compat.v1.constant('hello')
    assert hello.graph is g

sess = tf.compat.v1.Session(graph=g)

print(sess.run(sum1))


tensorflow-gpu2.0 i don't know why. i am a beginner of tensorflow

like image 320
smallKing Avatar asked Aug 04 '26 09:08

smallKing


1 Answers

After import tensorflow need disable eager execution, like below:

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

It's worked for me.

like image 197
Stas Oknedis Avatar answered Aug 07 '26 00:08

Stas Oknedis