Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core/train.py里113行附近错误提示不清晰 #800

Closed
parap1uie-s opened this issue Jan 25, 2021 · 2 comments
Closed

core/train.py里113行附近错误提示不清晰 #800

parap1uie-s opened this issue Jan 25, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@parap1uie-s
Copy link
Contributor

    train_dataset = cfg.train_dataset
    if not train_dataset:
        raise RuntimeError(
            'The training dataset is not specified in the configuration file.')
    val_dataset = cfg.val_dataset if args.do_eval else None

train.py 113行附近,train_dataset是一个类对象object

if not train_dataset这种判断,它实际上会做三个判断:

if train_dataset.__nonzero__
if train_dataset.__len__ == 0
if train_dataset is None

如果开发者在自定义数据集和dataloader时,暂时没有实现dataloader里的self.file_list,file_list长度为0,那么即使dataloader被正确实例化了,也会触发if not这里的错误提示。

原因:

dataloader的基类,dataset.py / Dataset,在163行的位置,又重写了__len__方法,使得if not train_dataset判断的实际上是if len(train_dataset.file_list) == 0

自然就会命中这个if了

修改建议:将现在line113@train.py的 if判断拆分为

if train_dataset is None:
   ....
if len(train_dataset) == 0:
  ....

这样若干条不同情况的提示,以免给开发者造成误导

@michaelowenliu
Copy link
Collaborator

@parap1uie-s Hi, thanks for your feedback. Fix the issue soon.

@michaelowenliu michaelowenliu added the bug Something isn't working label Jan 28, 2021
@michaelowenliu
Copy link
Collaborator

@parap1uie-s Done. #808

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants