使用Pytorch运行过去别人深度学习的代码出现:No module named 'tokenizer'


原文:

https://github.com/DeepRNN/image_captioning/issues/27

递归点击链接:

https://docs.python.org/2.5/whatsnew/pep-328.html

解决方法:

Update: I solve this issue by using relative import. Namely, e.g. change

译:Update:我使用相对导入解决了这个问题。也就是说,例如改变

from tokenizer.ptbtokenizer import PTBTokenizer

to

from .tokenizer.ptbtokenizer import PTBTokenizer

I am thinking this results from different python versions (I am using python 3.6 while coco-caption metrics is for 2.7). Another solution is use the coco-caption metrics for python3.

译:我认为这是不同python版本的结果(我使用的是python 3.6,而coco caption metrics是针对2.7的)。另一个解决方案是使用python3的coco字幕指标。

相关