Skip to content Skip to sidebar Skip to footer

"TypeError: 'Session' Object Is Not Callable" Error Running Sess = Tf.compat.v1.Session()(graph=tf.compat.v1.get_default_graph(), Config=session_conf)

I'm trying to set seeds and configure keras settings to ensure my experiments are reproducible. When I run the following (based on code in an answer to this question): # Import lib

Solution 1:

On the line second to last, you probably want to construct a Session object using the arguments graph and config, not call a Session.

Change this:

sess = tf.compat.v1.Session()(graph=tf.compat.v1.get_default_graph(), config=session_conf)

to this:

sess = tf.compat.v1.Session(graph=tf.compat.v1.get_default_graph(), config=session_conf)

You will also need to change the code in the fourteenth line:

from tensorflow.compat.v1.keras import backend as K

Since Tensorflow 2.0, Keras does not expose sessions in the backend like before. You can get around that by using the compat.v1 API, but this is soon to be deprecated.


Post a Comment for ""TypeError: 'Session' Object Is Not Callable" Error Running Sess = Tf.compat.v1.Session()(graph=tf.compat.v1.get_default_graph(), Config=session_conf)"