You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
train.py 113行附近,train_dataset是一个类对象object
if not train_dataset这种判断,它实际上会做三个判断:
如果开发者在自定义数据集和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判断拆分为
这样若干条不同情况的提示,以免给开发者造成误导
The text was updated successfully, but these errors were encountered: