Using tensorflow 2.X fails with "module 'tensorflow' has no attribute 'Session'"
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
An update - I got it to work by replacing the line
import tensorflow as tf
by
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
in both stressrnn.py and model.py before installing. So if there's no better workaround, would be good to add that to the install instructions.
When using TensorFlow v2.X, the speed of the project is greatly reduced, several times.
But now I have made a small update and added support for TensorFlow v2.X "out of the box". Although, at the moment it is better to use the project with ONNX Runtime, it works faster.