Tensorflow 2.0 Syntax Change
I have the following lines of codes that i would like to run and it's written based on the tensorflow 1.0 syntax: import tensorflow as tf a = tf.constant(5) b = tf.constant(2) c =
Solution 1:
try to use tf.compat.v1.Session
inplace of Session
other than this for more doubts you can refer to tensorflow
https://www.tensorflow.org/api_docs/python/tf/compat/v1/Session
Solution 2:
Here is updated code following this migration document
import tensorflow.compat.v1 as tf
tf.compat.v1.disable_v2_behavior()
a = tf.constant(5)
b = tf.constant(2)
c = tf.constant(3)
d = tf.multiply(a,b)
e = tf.add(b,c)
f = tf.subtract(d,e)
with tf.Session() as sess:
fetches = [a,b,c,d,e,f]
outs = sess.run(fetches)
print("outs={}".format(outs))
Post a Comment for "Tensorflow 2.0 Syntax Change"