Explore Courses Blog Tutorials Interview Questions
0 votes
in Data Science by (18.4k points)

When I execute the command

sess = tf.Session()

I am getting the below error:

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

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

System Information:

  • OS Platform and Distribution: Windows 10
  • Python Version: 3.7.1
  • Tensorflow Version: 2.0.0-alpha0 (installed with pip)

Steps to reproduce:


pip install --upgrade pip

pip install tensorflow==2.0.0-alpha0

pip install keras

pip install numpy==1.16.2


import tensorflow as tf

Execute command: sess = tf.Session()

1 Answer

0 votes
by (36.8k points)
edited by

For TF 1:1 Symbols Map, in TF 2.0 you have to use:

tf.compat.v1.Session() instead of tf.Session()

But one cannot benefit many improvements made from TF 2.0.

If you are a beginner and want to know more about Data Science the do check out the Data Science course

Browse Categories