Dimsmary / Ossas_ChatBot

chatbot with Keras
MIT License
454 stars 65 forks source link

MacOS下搭建模型的问题 #8

Closed Fidelxyz closed 4 years ago

Fidelxyz commented 4 years ago

Python版本:3.8.2 MacOS下clone项目代码编译运行。

Sat Apr 11 15:32:39 2020 读取训练数据...
Building prefix dict from the default dictionary ...
Loading model from cache /var/folders/rf/smxg24sn2pd7945k1wjwrzf00000gn/T/jieba.cache
Loading model cost 1.216 seconds.
Prefix dict has been built successfully.
Traceback (most recent call last):
  File "/Users/xxx/Documents/GitHub/Ossas_ChatBot/main.py", line 108, in <module>
    rnn.pre_precess()
  File "/Users/xxx/Documents/GitHub/Ossas_ChatBot/Seq2Seq.py", line 288, in pre_precess
    with open(dict_path, 'w') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/xxx/Documents/GitHub/Ossas_ChatBot/workspace/train_data/words_dictionary.txt'

在搭建模型时,报错为无法找到words_dictionary.txt

Dimsmary commented 4 years ago

需要手动创建 .../workspace/train_data 目录

Fidelxyz commented 4 years ago

手动创建目录后问题已解决,但构建训练模型时出现问题,报错信息如下:

Sun Apr 12 15:29:59 2020 构建训练模型...
Traceback (most recent call last):
  File "/Users/xxx/Documents/GitHub/Ossas_ChatBot/main.py", line 109, in <module>
    rnn.setup_model()
  File "/Users/xxx/Documents/GitHub/Ossas_ChatBot/Seq2Seq.py", line 134, in setup_model
    attention = Flatten()(attention)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py", line 781, in __call__
    self._set_mask_metadata(inputs, outputs, previous_mask)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py", line 842, in _set_mask_metadata
    output_mask = self.compute_mask(inputs, previous_mask)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1036, in compute_mask
    raise TypeError('Layer ' + self.name + ' does not support masking, '
TypeError: Layer flatten does not support masking, but was passed an input_mask: Tensor("encoder_Embedding/NotEqual:0", shape=(?, ?), dtype=bool)
Dimsmary commented 4 years ago

代码当前使用的tensorflow版本为2.1.0, 在python版本为3.7下运行正常。 能否尝试更换tensorflow版本?

Fidelxyz commented 4 years ago

更换版本后问题已解决。 Thanks!

Fidelxyz commented 4 years ago

另外报告一个小问题:xlsxwriter也应被写进requirements.txt里。

Dimsmary commented 4 years ago

requirements已更新。感谢