Hi I've started learning machine learning by TensorFlow. I've learned codes below and realized that these doesn't work anymore.
sess = tf.Session()
print(sess.run(hello))
print(sess.run([a, b, c]))
sess.close
It would be grateful someone can help me how to change these codes work. Since I'm not English native and this is my first question on Stack overflow, I'm sorry for if you feel any uncomfort
In Tensorflow 2.0, You can use tf.compat.v1.Session() instead of tf.session()
Please refer code in TF 1.X in below
%tensorflow_version 1.x
import tensorflow as tf
print(tf.__version__)
with tf.Session() as sess:
output = tf.constant(""Hello, World"")
print(sess.run(output).decode())
sess.close()
Output:
1.15.2
Hello, World
Please refer code in TF 2.X in below
%tensorflow_version 2.x
import tensorflow as tf
print(tf.__version__)
with tf.compat.v1.Session() as sess:
output = tf.constant(""Hello, World"")
print(sess.run(output).decode())
sess.close()
Output:
2.2.0-rc3
Hello, World
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With