Traceback (most recent call last): File "D:/pythonProject/test2.py", line 46, in <module> for i, data in enumerate(trainloader, 0): File "D:\pythonProject\venv\lib\site-packages\torch\utils\data\dataloader.py", line 359, in __iter__ return self._get_iterator() File "D:\pythonProject\venv\lib\site-packages\torch\utils\data\dataloader.py", line 305, in _get_iterator return _MultiProcessingDataLoaderIter(self) File "D:\pythonProject\venv\lib\site-packages\torch\utils\data\dataloader.py", line 918, in __init__ w.start() File "D:\Anaconda\lib\multiprocessing\process.py", line 105, in start self._popen = self._Popen(self) File "D:\Anaconda\lib\multiprocessing\context.py", line 223, in _Popen return _default_context.get_context().Process._Popen(process_obj) File "D:\Anaconda\lib\multiprocessing\context.py", line 322, in _Popen return Popen(process_obj) File "D:\Anaconda\lib\multiprocessing\popen_spawn_win32.py", line 65, in __init__ reduction.dump(process_obj, to_child) File "D:\Anaconda\lib\multiprocessing\reduction.py", line 60, in dump ForkingPickler(file, protocol).dump(obj) _pickle.PicklingError: Can't pickle <function <lambda> at 0x00000190FCFD0D90>: attribute lookup <lambda> on __main__ failed Process finished with exit code 1
时间: 2023-06-13 13:09:05 浏览: 418
这个错误是因为在使用 PyTorch 的 DataLoader 的时候,出现了不能序列化的函数对象,可能是因为你的函数对象 lambda 没有被正确定义或者引用。你可以尝试改变你的代码,或者检查你的代码中是否存在没有被正确定义或者引用的函数对象。另外,你可以考虑使用 PyTorch 的 multiprocessing 库来解决这个问题。
阅读全文