** 问题遇到的现象和发生背景**
在进行自建数据集进行data.DataLoader时的时候
问题相关代码,请勿粘贴截图
train_set = MiddleDataset(config.dataset_path, transform_train, 'train') # 这一步报的错__
self.train_loader = data.DataLoader(dataset=train_set, batch_size=config.batch_size, shuffle=True, num_workers=1)
** 运行结果及报错内容 **
前两个为python内置代码里的异常,
File "E:\PycharmProjects\pythonProject\venv\lib\site-packages\torch\utils\data\sampler.py", line 101, in init if not isinstance(self.num_samples, int) or self.num_samples <= 0:
File "E:\PycharmProjects\pythonProject\venv\lib\site-packages\torch\utils\data\sampler.py", line 109, in num_samples return len(self.data_source)
TypeError: object of type 'MiddleDataset' has no len()
求一个解决的办法!!__