smilelight / lightNLP

基于Pytorch和torchtext的自然语言处理深度学习框架。
Apache License 2.0
823 stars 212 forks source link

文本生成,语言模型 示例 报错 ModuleNotFoundError: No module named 'lightnlp.tg.cb.models' #9

Closed NeroSong closed 4 years ago

NeroSong commented 4 years ago

Mac 最新版本,按照Readme完成安装。 example目录执行python3 ./test_lm.py,报错:

Traceback (most recent call last):
  File "./test_lm.py", line 5, in <module>
    from lightnlp.tg import LM
  File "/usr/local/lib/python3.7/site-packages/lightnlp/tg/__init__.py", line 3, in <module>
    from .cb.module import CB
  File "/usr/local/lib/python3.7/site-packages/lightnlp/tg/cb/module.py", line 16, in <module>
    from .model import CBConfig, CBSeq2Seq
  File "/usr/local/lib/python3.7/site-packages/lightnlp/tg/cb/model.py", line 2, in <module>
    from .models.encoder import Encoder
ModuleNotFoundError: No module named 'lightnlp.tg.cb.models'
smilelight commented 4 years ago

感谢试用提醒,发现确有个bug。现在已修复~

NeroSong commented 4 years ago

感谢试用提醒,发现确有个bug。现在已修复~

git pull 到最新版本后,还是报同样的错误。 是我哪里配置有问题嘛🤔

smilelight commented 4 years ago

@NeroSong 额,你现在安装的是0.4.1吗,我这里测试了一下,发明没问题。 Snipaste_2019-12-31_12-23-25.jpg 当然也可能是我这里的问题。。。

NeroSong commented 4 years ago

@smilelight Sorry刚才确实忘了更新pip,只是拉了下repo😅 更新后出现了新的报错:

截屏2019-12-31下午12 40 03
Traceback (most recent call last):
  File "./test_lm.py", line 16, in <module>
    lm_model.load('./lm_saves')
  File "/usr/local/lib/python3.7/site-packages/lightnlp/tg/lm/module.py", line 62, in load
    config = LMConfig.load(save_path)
  File "/usr/local/lib/python3.7/site-packages/lightnlp/base/model.py", line 18, in load
    with open(config_path, 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: './lm_saves/config.pkl'
smilelight commented 4 years ago

@NeroSong 模型要先训练然后才能加载预测部署等。把train这一行取消注释,然后还需要手动设置TensorBoard日志的保存位置log_dir才可以(其他参数都可选,有默认选项) Snipaste_2019-12-31_13-01-52.jpg

NeroSong commented 4 years ago

@smilelight 根据实例文档找到了字向量的数据。 非常好用,感谢作者! 期待以后能有更多发展👍