pender / chatbot-rnn

A toy chatbot powered by deep learning and trained on data from Reddit
MIT License
900 stars 371 forks source link

no module named tensorflow.contrib #65

Open akarthik2014 opened 4 years ago

akarthik2014 commented 4 years ago

Exception has occurred: ModuleNotFoundError No module named 'tensorflow.contrib'

101Priyanshi commented 4 years ago

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

wmodes commented 4 years ago

Any suggestions for using Tensorflow 2.x?

Alyetama commented 3 years ago

Any suggestions for using Tensorflow 2.x?

Option 1:

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:

git clone https://github.com/Alyetama/chatbot-rnn.git
breadbrowser commented 2 years ago

pip install tensorflow==1.15

breadbrowser commented 2 years ago

is all you need to do

breadbrowser commented 2 years ago

no editing

breadbrowser commented 2 years ago

needed