Skip to content

Using tensorflow 2.X fails with "module 'tensorflow' has no attribute 'Session'" #1

@xivarri

Description

@xivarri

Thanks for making this!
Unfortunately I can't seem to get the install down - I have to use tensorflow2.X because python3.8 doesn't support 1.X, and for some reason I cannot get a 3.6 or 3.7 virtualenv to work - and while the install seems to work, when trying to instantiate a StressRNN, I get:

<ipython-input-4-f44bb10095c3> in <module>
----> 1 stress_rnn = StressRNN()

~/gits/StressRNN/stressrnn/stressrnn.py in __init__(self, f_name_add_exception_dict)
     64         self.graph = tf.Graph()
     65         with self.graph.as_default():
---> 66             self.session = tf.Session(graph=self.graph)
     67             with self.session.as_default():
     68                 self.model = tf.keras.models.model_from_json(model_json)

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

The internet seems to suggest running

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

But doing that in an interpreter at least before importing StressRNN doesn't seem to work.
Is there any workaround?
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions