load数据集训练模型时报错,并不是加载模型参数的问题,而是数据读取失败。网上都是加载模型失败的解决方案,因此记录一下数据加载失败的解决方法。

具体报错信息:

Traceback (most recent call last):
  File "imodel_train.py", line 255, in <module>
    train_inter(args)
  File "imodel_train.py", line 152, in train_inter
    train_dataset = train_DHBDataset(root=args.train_root, npoints=args.npoints, train=True)
  File "/root/InterPC/Inter-pc-main/inter-pc1/datasets/dhb_set.py", line 21, in __init__
    self.total_dataset = self.get_dataset()
  File "/root/InterPC/Inter-pc-main/inter-pc1/datasets/dhb_set.py", line 32, in get_dataset
    total_tensor = torch.load(datapt)
  File "/root/.local/conda/envs/cp1/lib/python3.6/site-packages/torch/serialization.py", line 595, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/root/.local/conda/envs/cp1/lib/python3.6/site-packages/torch/serialization.py", line 764, in _legacy_load
    magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, '\x00'.

解决方法:

数据集所在的文件夹里存在隐藏文件,ls指令无法查出,建议看看数据读取路径下,执行ls -a检查,删除隐藏文件or乱码文件后,成功load数据,开始训练。

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐