I have installed tensorflow from Source on Ubuntu 16.10 environment. Everything went smooth but now on compiling a program, it shows the following error:
Traceback (most recent call last):
File "ff.py", line 3, in <module>
sess = tf.InteractiveSession()
AttributeError: module 'tensorflow' has no attribute 'InteractiveSession'
Didn't find any post related to this. Could someone please help?
sess=tf.compat.v1.InteractiveSession()
Use above line instead of sess = tf.InteractiveSession()
line, if you are using tesorflow 2.0.0 version
The error causes from Tensorflow version. When you've install v2.x and try to use v1.x, you'll get this error. To avoid this,
import tensorflow as tf
import tensorflow.compat.v1 as tfc
Use tfc instead of tf when you get the same error on the other functions like:
sess = tfc.InteractiveSession()
my_tensor = tfc.random_uniform((4, 4), 0, 1)
print(my_tensor)
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