chatbot-rnn
chatbot-rnn copied to clipboard
no module named tensorflow.contrib
Exception has occurred: ModuleNotFoundError No module named 'tensorflow.contrib'
since your issue is not very old so I guess you have Tensorflow 2.0.x installed in your machine but tensorflowf.contrib no longer exists in tensorflow 2.0.x, it was there in Tensorflow 1.x
Any suggestions for using Tensorflow 2.x?
Any suggestions for using Tensorflow 2.x?
- First, install
tensorflow_addons
:
pip install tensorflow-addons
Option 1:
- Run the following script in the repository's directory:
from glob import glob
def update(find, replacement):
for file in glob('*.py'):
with open(file) as f:
s = f.read().replace(find, replacement)
with open(file, 'w') as f:
f.write(s)
update('import tensorflow as tf', '''import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
import tensorflow_addons as tfa''')
update('tf.contrib.rnn.LSTMStateTuple', 'tf.compat.v1.nn.rnn_cell.LSTMStateTuple')
update('from tensorflow.contrib import rnn', '')
update('rnn.NASCell', 'tfa.rnn.NASCell')
Option 2:
- Clone my fork, which is compatible with TensorFlow v2.x:
git clone https://github.com/Alyetama/chatbot-rnn.git
pip install tensorflow==1.15
is all you need to do
no editing
needed