AttributeError module tensorflow compat has no attribute v1

0 votes

i am building an Rasa chatbot but there is an error in tensorflow AttributeError: module 'tensorflow.compat' has no attribute 'v1'

i am trying changing tensorflow versions but not found a correct version Note : my tensorflow version is 1.9 please help me thanks in advance.

```

from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from rasa_core import utils
from rasa_core.agent import Agent
from rasa_core.policies.keras_policy import KerasPolicy
from rasa_core.policies.memoization import MemoizationPolicy
from rasa_core.policies.sklearn_policy import SklearnPolicy

if __name__ == '__main__':
    utils.configure_colored_logging(loglevel='DEBUG')
    training_data_file = '/home/zain/Ai chatbots/horoscope_bot/data/stories.md'
    model_path = './models/dialogue'

    agent = Agent('/home/zain/Ai chatbots/horoscope_bot/horoscope_domain.yml',
     policies=[MemoizationPolicy(max_history = 5), KerasPolicy()])
    training_data = agent.load_data(training_data_file)

    agent.train(
        training_data,
        augmentation_factor = 50,
        epochs = 500,
        batch_size = 10,
        # max_history = 5,
        validation_split = 0.2
    )

    agent.persist(model_path) ```

here is the error


```zain@zain-HP-ProBook-6460b:~$ /usr/bin/python3 /home/zain/Ai-chatbots/horoscope_bot/train_initialize.py
/home/zain/.local/lib/python3.6/site-packages/rasa_core/__init__.py:12: UserWarning: The 'rasa_core' package has been renamed. You should change your imports to use 'rasa.core' instead.
  UserWarning,
/home/zain/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:523: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/home/zain/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:524: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/home/zain/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
/home/zain/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/home/zain/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
/home/zain/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:532: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
Traceback (most recent call last):
  File "/home/zain/Ai-chatbots/horoscope_bot/train_initialize.py", line 8, in <module>
    from rasa_core.policies.keras_policy import KerasPolicy
  File "/home/zain/.local/lib/python3.6/site-packages/rasa/core/policies/keras_policy.py", line 35, in <module>
    class KerasPolicy(Policy):
  File "/home/zain/.local/lib/python3.6/site-packages/rasa/core/policies/keras_policy.py", line 62, in KerasPolicy
    max_history: Optional[int] = None,
AttributeError: module 'tensorflow.compat' has no attribute 'v1'```
Nov 4, 2019 in Machine Learning by Usman
• 120 points
3,852 views

1 answer to this question.

0 votes

Hi@Usman,

It seems you are using an older version of TensorFlow. This is not available in the older version of TensorFlow. You need to upgrade TensorFlow by using the below-given command. 

$ conda install tensorflow=2.2
answered Jul 19, 2020 by MD
• 95,460 points

Related Questions In Machine Learning

0 votes
1 answer

AttributeError: module 'tensorflow' has no attribute 'estimator'.

Hi@akhtar, There was an environment issue, tensorflow was ...READ MORE

answered Apr 23, 2020 in Machine Learning by MD
• 95,460 points
4,514 views
0 votes
1 answer

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

Hi@akhtar, In Tensorflow 2.0, there is no placeholder. ...READ MORE

answered Jul 13, 2020 in Machine Learning by MD
• 95,460 points
3,678 views
0 votes
1 answer

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

Hi@akhtar, In Tensorflow 2.0, there is no attribute named ...READ MORE

answered Jul 13, 2020 in Machine Learning by MD
• 95,460 points
6,398 views
0 votes
1 answer

AttributeError: module 'matplotlib' has no attribute 'scatter'

Hi@akhtar, To avoid this error, make sure you ...READ MORE

answered Apr 16, 2020 in Machine Learning by MD
• 95,460 points
11,498 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
0 votes
1 answer

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

Hi@akhtar, There may be problem in the versions. ...READ MORE

answered Apr 21, 2020 in Machine Learning by MD
• 95,460 points
11,602 views
0 votes
1 answer

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

Hi@akhtar, Tensorflow 2.0 has eager_execution enabled by default and ...READ MORE

answered Apr 21, 2020 in Machine Learning by MD
• 95,460 points
3,084 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP