1
votes

I am running python3.7.4 Shell program under tensorflow. When I input sess = tf.Session(),the command line prompt me that module 'tensorflow' has no attribute 'Session' this is the message : " Traceback (most recent call last): File "", line 1, in sess = tf.Session() AttributeError: module 'tensorflow' has no attribute 'Session'

> "

plz help

1

1 Answers

2
votes

You must be using tensorflow 2, which does not use session anymore but rather greedy execution. Please refer to their doc for more information.

Alternatively, there is a backward compatibility module: tensorflow.compat.v1 you can use like so:

>>> import tensorflow.compat.v1 as tf
>>> tf.Session()