AttributeError:模块“ tensorflow.compat”没有属性“ v1”

时间:2019-11-03 18:04:26

标签: python tensorflow

我正在构建Rasa聊天机器人,但tensorflow中有错误 AttributeError:模块“ tensorflow.compat”没有属性“ v1”

我正在尝试更改张量流版本,但未找到正确的版本 注意:我的tensorflow版本是1.9 请提前帮助我。

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'```

0 个答案:

没有答案