Closed QyDing02 closed 2 years ago
https://github.com/cheneydon/efficient-bert/blob/28bca740c6be1c217e2817afd1480c1d6dc71548/create_pretrain_feature.py#L49-L52
这里你需要确定train_dir
下是否有epoch_xx_metrics.json
这样的文件,是通过create_pretrain_data.sh
这个文件生成的,程序会读取每个json文件里的num_training_examples
项值。不过在create_pretrain_feature.py
这个阶段total_examples
没有被使用,相关代码也可以注释掉
经过调试,我找到了解决方案:
https://github.com/cheneydon/efficient-bert/blob/28bca740c6be1c217e2817afd1480c1d6dc71548/create_pretrain_feature.py#L36-L39
可能是我的环境问题,这里的args.book_dir
和args.concate_data_dir
两个参数,当路径为空的时候并没有识别成false,而是PosixPath('.')
,导致无论输入的路径来自wikipedia还是bookcorpus,条件都成立,默认进入第37行(all_train_dir = [args.wiki_dir, args.book_dir]
)这一分支。
当输入路径只有wikipedia的路径时,
all_train_dir=[PosixPath('dataset/pretrain_data/wikipedia_nomask'),Posixpath('.')]
,
all_train_dir[1]
是空路径,引起后续的报错。
当我这样修改之后:
tmp_path=Path()
if args.book_dir!=tmp_path and args.concate_data_dir!=tmp_path:
all_train_dir = [args.wiki_dir, args.book_dir]
else:
all_train_dir = [args.wiki_dir]
程序能正常运行了。
嗯,好的
当我运行create_pretrain_feature.sh 中的如下一段时(Wikipedia only 的那一段),即:
会报这个错误:
我不知道导致
len(num_epoch_examples)==0
的原因是什么。 而且奇怪的是,当跳过这段代码,执行Wikipedia + BooksCorpus那一段的时候,即:一切正常,bookcorpus_nomask、wiki_book_nomask、 wikipedia_nomask这三个文件夹里各保存了5个data_epoch_x的文件。
请问是哪里出了问题?