请问:
在代码运行的过程中出现以下报错,是哪里出现问题了呢?
Traceback (most recent call last):
File "D:/Downloads/prnet-master/main.py", line 177, in <module>
main()
File "D:/Downloads/prnet-master/main.py", line 145, in main
train_loader = DataLoader(ModelNet40(num_points=args.n_points,
File "D:\pythonproject3.8\lib\site-packages\torch\utils\data\dataloader.py", line 353, in __init__
sampler = RandomSampler(dataset, generator=generator) # type: ignore[arg-type]
File "D:\pythonproject3.8\lib\site-packages\torch\utils\data\sampler.py", line 109, in __init__
raise ValueError("num_samples should be a positive integer "
ValueError: num_samples should be a positive integer value, but got num_samples=<bound method RandomSampler.num_samples of <torch.utils.data.sampler.RandomSampler object at 0x000001932A20E820>>
部分代码如下:
data_source: Sized
def __init__(self, data_source: Sized) -> None:
self.data_source = data_source
def __iter__(self) -> Iterator[int]:
return iter(range(len(self.data_source)))
def __len__(self) -> int:
return len(self.data_source)
class RandomSampler(Sampler[int]):
data_source: Sized
replacement: bool
def __init__(self, data_source: Sized, replacement: bool = False,
num_samples: Optional[int] = None, generator=None) -> None:
self.data_source = data_source
self.replacement = replacement
self._num_samples = num_samples
self.generator = generator
if not isinstance(self.replacement, bool):
raise TypeError("replacement should be a boolean value, but got "
"replacement={}".format(self.replacement))
if not isinstance(self.num_samples, int) or self.num_samples <= 0:
raise ValueError("num_samples should be a positive integer " #此处报错
"value, but got num_samples={}".format(self.num_samples))