【error】invalid argument 1: must be strictly positive at /pytorch/torch/lib/TH/generic/THTenso

ERROR:
RuntimeError: invalid argument 1: must be strictly positive at /pytorch/torch/lib/TH/generic/THTensorMath.c:2184


具体:
  File "main.py", line 152, in test
    for batch_idx, (image, captions, lengths) in enumerate(valtest_loader, 1): 
  File "/。。/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 310, in __iter__
    return DataLoaderIter(self)
  File "/。。。/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 180, in __init__
    self._put_indices()
  File "/。。。/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 219, in _put_indices
    indices = next(self.sample_iter, None)
  File "/。。/anaconda3/lib/python3.6/site-packages/torch/utils/data/sampler.py", line 119, in __iter__
    for idx in self.sampler:
  File "/。。/anaconda3/lib/python3.6/site-packages/torch/utils/data/sampler.py", line 50, in __iter__
    return iter(torch.randperm(len(self.data_source)).long())
RuntimeError: invalid argument 1: must be strictly positive at /pytorch/torch/lib/TH/generic/THTensorMath.c:2184
 

在此记录下曾经遇到过这种错误

这个错误原因为valtest_loader的构建出现问题,已解决。

你可能感兴趣的:(随记)