IndexError: Caught IndexError in DataLoader worker process 0.

问题遇到的现象和发生背景

ssd跑自制数据集显示:
IndexError: Caught IndexError in DataLoader worker process 0.

问题相关代码,请勿粘贴截图
 def reraise(self):
    r"""Reraises the wrapped exception in the current thread"""
    # Format a message such as: "Caught ValueError in DataLoader worker
    # process 2. Original Traceback:", followed by the traceback.
    msg = "Caught {} {}.\nOriginal {}".format(
        self.exc_type.__name__, self.where, self.exc_msg)
    if self.exc_type == KeyError:
        # KeyError calls repr() on its argument (usually a dict key). This
        # makes stack traces unreadable. It will not be changed in Python
        # (https://bugs.python.org/issue2651), so we work around it.
        msg = KeyErrorMessage(msg)
    elif getattr(self.exc_type, "message", None):
        # Some exceptions have first argument as non-str but explicitly
        # have message field
        raise self.exc_type(message=msg)
    raise self.exc_type(msg)
运行结果及报错内容

File "C:\Users\huayuan001.conda\envs\pyqxr\lib\site-packages\torch\utils\data\dataloader.py", line 1225, in _process_data
data.reraise()
File "C:\Users\huayuan001.conda\envs\pyqxr\lib\site-packages\torch_utils.py", line 429, in reraise
raise self.exc_type(msg)
IndexError: Caught IndexError in DataLoader worker process 0.

我的解答思路和尝试过的方法

将num_workers设置为0。
parser.add_argument('--num_workers', default=0, type=int,
help='Number of workers used in dataloading')

我想要达到的结果

解决DataLoader进程问题

你这个应该是数据的问题,不是进程的问题,你把数据和标签打印下来看看。打印数据的shape和标签的shape